Locking data

Malte no at valid.mail
Wed May 23 13:20:55 UTC 2018

On Tuesday, 22 May 2018 at 21:45:07 UTC, IntegratedDimensions 
> an idea to lock data by removing the reference:
> class A
> {
>    Lockable!Data data;
> }
> [...]

This sounds like you are looking for is an atomic swap. Afaik it 
doesn't exist in the standard library. You could use asm for the 
XCHG, but that would make your code x86 dependent.
I think the easiest way would be to just use a mutex and tryLock.

More information about the Digitalmars-d-learn mailing list