You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor engine: model Awaiter with unique ownership
No changelog entry intended, no effects on API or measurable effects on performance.
* `engine::impl::Awaiter` is now passed around in `AwaiterPtr`, which is a `unique_ptr` with a custom deleter that decrements the intrusive refcounter of `TaskContext` calls virtual `PolymorphicAwaiter::DisposeWithoutNotification` on destruction.
* Rationale:
* `unique_ptr` better suits `AwaitableBase` API, which are the majority of awaitables. Only legacy `WaitAny` actually copies the `intrusive_ptr`.
* `unique_ptr` better suits most awaiters, which don't support being notified concurrently. And those that do can easily add an explicit `AsAwaiterPtr` method, see e.g. `WaitAnyContext::Impl`.
* Making an expensive locked increment an explicit operation can be seen as an additional benefit.
* The existing performance of `TaskContext` awaiter is maintained, there are still no virtual calls for this kind of `Awaiter`.
* Moved the atomic refcount from `Awaiter` to `TaskContext`.
* Added `IntrusiveRefCounterOne` as a common place for intrusive refcounter that initializes to 1 instead of 0 (that place was `Awaiter` previously).
commit_hash:3170fb506a660a90af55e129ff22f8c9a9b677bb
0 commit comments