On Wednesday, 23 May 2018 at 13:24:35 UTC, rikki cattermole wrote:
On 24/05/2018 1:20 AM, Malte wrote:
On Tuesday, 22 May 2018 at 21:45:07 UTC, IntegratedDimensions wrote:
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.

What are you talking about? :p

http://dpldocs.info/experimental-docs/core.atomic.cas.1.html

That is Compare-and-set.
To make an exchange using cas I first have to read the value, then write to it expecting to be still the value I read before. That are more instructions than just a swap. If a cas fails, I have to redo everything. An exchange never fails, I just might not get the result I would like to have (null instead of pointer).

Reply via email to