Subj : Re: Memory visibility and MS Interlocked instructions To : comp.programming.threads From : Alexander Terekhov Date : Thu Aug 25 2005 08:38 pm Scott Meyers wrote: [... busted CacheComputedValue()/FetchComputedValue() example ...] atomic iValue; atomic fValueHasBeenComputed(FALSE); int ComputeValue(); // http://tinyurl.com/68jav #pragma isolated_call(ComputeValue) void CacheComputedValue() { if (!fValueHasBeenComputed.load(msync::naked_competing)) { iValue.store(ComputeValue(), msync::naked_competing); fValueHasBeenComputed.store(TRUE, msync::ssb); } } BOOL FetchComputedValue(int *piResult) { if (fValueHasBeenComputed.load(msync::cchlb_true)) { *piResult = iValue.load(msync::naked_competing); return TRUE; } else return FALSE; } To Peter: I've extended cc* stuff with path specific variants so that you can give compiler a hint on which path you don't really need isync. regards, alexander. .