> I think a pthread spinlock would do nicely here. Perhaps, but maybe it's worth implementing it with platform-specific code where possible: say, lock cmpxcgh [X],Y on x86 for InterlockedCompareExchange plus general pthread version for portability? But I guess portability has more priority at this stage?