File tree Expand file tree Collapse file tree 4 files changed +17
-9
lines changed
Expand file tree Collapse file tree 4 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,10 @@ class QueueSpinLock final {
1616 host.Acquire (this );
1717 }
1818 ~Guard () {
19+ Release ();
20+ }
21+
22+ void Release () {
1923 host.Release (this );
2024 }
2125
Original file line number Diff line number Diff line change 88
99#include < components/intrusive/list.h>
1010#include < components/sync/spinLock.h>
11+ #include < components/sync/queue_spinlock.h>
1112#include < fiber/awaiter/awaiter.h>
1213
1314namespace NFibers {
@@ -16,25 +17,27 @@ template <class M>
1617class AsyncMutexWaiter : public IAwaiter ,
1718 public NComponents::Node<AsyncMutexWaiter<M>> {
1819public:
19- using Guard = std::unique_lock< typename M::Spinlock> ;
20+ using Guard = NSync::QueueSpinLock::Guard ;
2021
21- AsyncMutexWaiter (M* mutex , Guard guard)
22- : mutex(mutex ), guard(std::move( guard) ){};
22+ AsyncMutexWaiter (M* async_mutex , Guard& guard)
23+ : async_mutex(async_mutex ), guard(guard){};
2324
2425 void AwaitSuspend (StoppedFiber handle) override {
2526 assert (handle.IsValid ());
2627
2728 stopped_handle = handle;
28- mutex->Park (this );
29- guard.release ()->unlock ();
29+ async_mutex->Park (this );
30+
31+ // guard.release()->unlock();
32+ guard.Release ();
3033 }
3134
3235 void Schedule () { stopped_handle.Schedule (); }
3336
3437private:
35- M* mutex ;
38+ M* async_mutex ;
3639 StoppedFiber stopped_handle;
37- Guard guard;
40+ Guard& guard;
3841};
3942
4043} // namespace NFibers
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ namespace NFibers {
1111void AsyncMutex::Lock () {
1212 Waiter::Guard guard (spinlock_);
1313 if (locked_) {
14- Waiter waiter (this , std::move ( guard) );
14+ Waiter waiter (this , guard);
1515 Suspend (&waiter);
1616 } else {
1717 locked_ = true ;
Original file line number Diff line number Diff line change 88
99#include < components/intrusive/list.h>
1010#include < components/sync/spinLock.h>
11+ #include < components/sync/queue_spinlock.h>
1112#include < fiber/awaiter/mutex_awaiter.h>
1213
1314namespace NFibers {
1415
1516class AsyncMutex {
16- using Spinlock = NSync::SpinLock ;
17+ using Spinlock = NSync::QueueSpinLock ;
1718 using Waiter = AsyncMutexWaiter<AsyncMutex>;
1819
1920 friend Waiter;
You can’t perform that action at this time.
0 commit comments