So, here is my special utility for double checking: this is a static method in which you pass the criteria, the synchronization object and the action that needs to be performed.
public static bool RunIf(Func<bool> criterion, object syncObject, Action action) { if (criterion()) lock(syncObject) if (criterion()) { Thread.MemoryBarrier(); action(); return true; } return false; }
I was given to understand that, according to the C # specification, optimizers can change the memory allocation order so that without a memory barrier this method can give a false positive result and perform an action when it should "t.
In my small world, if such a failure is possible, it should also be possible to develop a test that will demonstrate failure successively, hit hard enough with a script with enough parallel test cases. I’ve been looking for such a test for about a year, but so far I have drawn a space. Can someone show me a test that:
Rob lyndon
source share