On 4 April 2014 22:54, Sven Van Caekenberghe <sven@stfx.eu> wrote:

On 04 Apr 2014, at 19:29, Igor Stasenko <siguctua@gmail.com> wrote:

> On 4 April 2014 18:31, Sven Van Caekenberghe <sven@stfx.eu> wrote:
> Just for the sake of discussion, you try to prevent interruptions by using assignments, right ? But you still need #== which seems like a (potential) message send, which brings us back to the other arguments in this thread. Furthermore, the dummy value must be different for each of the processes/threads entering, no ?
>
> dummy is placeholder used solely to detect that counter is 'locked' via #== comparison..
> can be any object not really matters if you share it among processes or not,
> since it carries no state.
>
> #== , whileTrue: .. as well as any other message sends potentially is subject of being interrupted.. but there's nothing wrong with it, as long as two assignments (in a row)
> don't have chance to be interrupted.

All this is quite interesting (and makes my head hurt), maybe we should implement this as a helper class in the image, along side the other lock free stuff ?

i don't know.. do you think it shall be part of some 'atomics' library?

From other side, for same problem there can be many different solutions..
For instance, if you need to uniquely identify an object, what can be simpler than just using that object (identity)?
And simplest way to obtain unique object, which nobody can read/write to, is to allocate a new one..
and as long as you don't give a reference to it, it is free from any concurrency caveats..


--
Best regards,
Igor Stasenko.