File tree 4 files changed +17
-9
lines changed
4 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,10 @@ class QueueSpinLock final {
16
16
host.Acquire (this );
17
17
}
18
18
~Guard () {
19
+ Release ();
20
+ }
21
+
22
+ void Release () {
19
23
host.Release (this );
20
24
}
21
25
Original file line number Diff line number Diff line change 8
8
9
9
#include < components/intrusive/list.h>
10
10
#include < components/sync/spinLock.h>
11
+ #include < components/sync/queue_spinlock.h>
11
12
#include < fiber/awaiter/awaiter.h>
12
13
13
14
namespace NFibers {
@@ -16,25 +17,27 @@ template <class M>
16
17
class AsyncMutexWaiter : public IAwaiter ,
17
18
public NComponents::Node<AsyncMutexWaiter<M>> {
18
19
public:
19
- using Guard = std::unique_lock< typename M::Spinlock> ;
20
+ using Guard = NSync::QueueSpinLock::Guard ;
20
21
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){};
23
24
24
25
void AwaitSuspend (StoppedFiber handle) override {
25
26
assert (handle.IsValid ());
26
27
27
28
stopped_handle = handle;
28
- mutex->Park (this );
29
- guard.release ()->unlock ();
29
+ async_mutex->Park (this );
30
+
31
+ // guard.release()->unlock();
32
+ guard.Release ();
30
33
}
31
34
32
35
void Schedule () { stopped_handle.Schedule (); }
33
36
34
37
private:
35
- M* mutex ;
38
+ M* async_mutex ;
36
39
StoppedFiber stopped_handle;
37
- Guard guard;
40
+ Guard& guard;
38
41
};
39
42
40
43
} // namespace NFibers
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ namespace NFibers {
11
11
void AsyncMutex::Lock () {
12
12
Waiter::Guard guard (spinlock_);
13
13
if (locked_) {
14
- Waiter waiter (this , std::move ( guard) );
14
+ Waiter waiter (this , guard);
15
15
Suspend (&waiter);
16
16
} else {
17
17
locked_ = true ;
Original file line number Diff line number Diff line change 8
8
9
9
#include < components/intrusive/list.h>
10
10
#include < components/sync/spinLock.h>
11
+ #include < components/sync/queue_spinlock.h>
11
12
#include < fiber/awaiter/mutex_awaiter.h>
12
13
13
14
namespace NFibers {
14
15
15
16
class AsyncMutex {
16
- using Spinlock = NSync::SpinLock ;
17
+ using Spinlock = NSync::QueueSpinLock ;
17
18
using Waiter = AsyncMutexWaiter<AsyncMutex>;
18
19
19
20
friend Waiter;
You can’t perform that action at this time.
0 commit comments