Add simple SharedMutex to folly::coro
Summary: Adds a simple SharedMutex type to the folly::coro namespace. The `co_[scoped_]lock[_shared]()` methods return semi-awaitables that require the caller to provide an executor to resume on in the case that the lock could not be acquired synchronously. This avoids some potential issues that could occur if the `.unlock()` operation were to resume awaiting coroutines inline. If you are awaiting within a `folly::coro::Task` then the current executor is implicitly provided. Otherwise, the caller can explicitly provide an executor by calling `.viaIfAsync()`. The implementation has not been optimised and currently just relies on a `SpinLock` to synchronise access to internal state. The main aim for this change is to make available a SharedMutex abstraction with the desired API that applications can start writing against which we can later optimise as required. Reviewed By: andriigrynenko Differential Revision: D9995286 fbshipit-source-id: aa141ad241d29daff2df5f7296161517c99ab8ef
Showing
This diff is collapsed.
Please register or sign in to comment