On Fri, Sep 13, 2019 at 6:27 PM Rhodri James <rho...@kynesim.co.uk> wrote:

> On 13/09/2019 17:07, Vinay Sharma wrote:
> > Please see my second mail in this thread, where I have comprehensively
> explained what I mean by atomic types.
> > It is nothing but multiprocessing.Value, which can have an Atomic
> variant to be used across processes.
>
> Doesn't multiprocessing.Value already have a lock option for this exact
> purpose?  How else would your atomic access work?
>

My summary from the thread:

The "atomicity" the OP asks for is an equivalent to the C++ <atomic>
abstraction (https://en.cppreference.com/w/cpp/header/atomic), which
eventually boils down to the platform hardware support. In other words, it
is really a hardware feature.

The other consequence is it makes only sense on "l-values" (C/C++), so the
natural adept for this feature implementation would be ctypes module. As
already suggested by the OP, there are actually already ctypes in
multiprocessing.sharedctypes which almost do that, but not quite. They use
lock for the synchronization, which is what the OP wants to avoid (there is
a significant difference between a lock and an atomic operation).

What seems a natural way to proceed would be extending
mulitprocessing.sharedctypes with 'AtomicValue', 'AtomicArray', etc which
will be the atomic counterparts of the already implemented objects in
sharedctypes, i.e. the objects for which the access will be handled by
platform atomic operations instead of non-atomic (standard) ones.

On the side note, when reading the docs about I am not sure I understand
what is actually the difference between the objects from multiprocessing
and multiprocessing.sharedctypes.

Richard
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/F6KA23EYRD3P3MNXBVHWCPZNXGFEELYE/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to