achimnol / aiotools

Idiomatic asyncio utilties
https://aiotools.readthedocs.io
MIT License
154 stars 12 forks source link

New module: sync #4

Open achimnol opened 7 years ago

achimnol commented 7 years ago

Add a new module called "sync" which provides a set of high-level synchronization primitives not offered in the standard library.

My first idea is AsyncBarrier: when all coroutines that share the same barrier object calls wait(), then they are all blocked until all of them calls wait(). If all has called wait(), resume their execution. Preferably, the API should look like threading.Barrier. Let's also write test suites for it.

Ideas for other synchronization primitives are welcome.