Eric,

> On 17 Jul 2018, at 20:35, Eric Snow <ericsnowcurren...@gmail.com> wrote:
> 
> With this in mind, here's how I'm approaching the problem:
> 
> 1. interp A "shares" an object with interp B (e.g. through a channel)
>    * the object is incref'ed under A before it is sent to B
> 2. the object is wrapped in a proxy owned by B
>    * the proxy may not make C-API calls that would mutate the object
> or even cause an incref/decref
> 3. when the proxy is GC'd, the original object is decref'ed
>    * the decref must happen in a thread in which A is running

How does the proxy at the same time make the object accessible and prevent 
mutation?

Would it help if there was an explicit owning thread for each object?

I'm thinking that you can do a fast check that the object belongs to the 
current thread and can use that knowledge to avoid locking.
If the object is owned by another thread acquire the GIL in the traditional way 
and mutating the state will be safe.

The "sharing" process can ensure that until an explicit "unsharing" the object 
remains safe to test in all threads that share an object,
avoiding the need for the special processor instructions.

Barry

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to