On Sun, Jun 25, 2017 at 3:09 PM, Nathaniel Smith <njs@pobox.com> wrote:
On Sun, Jun 25, 2017 at 2:13 PM, Chris Jerdonek <chris.jerdonek@gmail.com> wrote:
I'm using asyncio, and the synchronization primitives that asyncio exposes are relatively simple [1]. Have options for async read-write synchronization already been discussed in any detail?
As a general comment: I used to think rwlocks were a simple extension to regular locks, but it turns out there's actually this huge increase in design complexity. Do you want your lock to be read-biased, write-biased, task-fair, phase-fair? Can you acquire a write lock if you already hold one (i.e., are write locks reentrant)? What about acquiring a read lock if you already hold the write lock? Can you atomically upgrade/downgrade a lock? This makes it much harder to come up with a one-size-fits-all design suitable for adding to something like the python stdlib.
I agree. And my point about asyncio's primitives wasn't a criticism or request that more be added. I was asking more if there has been any discussion of general approaches and patterns that take advantage of the event loop's single thread, etc. Maybe what I'll do is briefly write up the approach I have in mind, and people can let me know if I'm on the right track. :) --Chris