File tree 4 files changed +9
-7
lines changed
4 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ class QueueSpinLock final {
42
42
43
43
private:
44
44
void Acquire (Guard* guard) {
45
- auto ancestor = tail_.exchange (guard, std::memory_order_acquire);
45
+ auto ancestor = tail_.exchange (guard/* , std::memory_order_acquire*/ );
46
46
if (ancestor == nullptr ) {
47
47
guard->SetOwner ();
48
48
return ;
Original file line number Diff line number Diff line change 7
7
#include < mutex>
8
8
9
9
#include < components/intrusive/list.h>
10
+ #include < components/sync/queue_spinlock.h>
10
11
#include < fiber/awaiter/awaiter.h>
11
12
12
13
namespace NFibers {
@@ -15,23 +16,23 @@ template <class W>
15
16
class WaitGroupWaiter : public IAwaiter ,
16
17
public NComponents::Node<WaitGroupWaiter<W>> {
17
18
public:
18
- using Guard = std::unique_lock< typename W::Spinlock> ;
19
+ using Guard = NSync::QueueSpinLock::Guard ;
19
20
20
- WaitGroupWaiter (W* wg, Guard guard) : wg(wg), guard(std::move( guard) ){};
21
+ WaitGroupWaiter (W* wg, Guard& guard) : wg(wg), guard(guard){};
21
22
22
23
void AwaitSuspend (StoppedFiber fiber) override {
23
24
assert (fiber.IsValid ());
24
25
25
26
stopped_fiber = fiber;
26
27
wg->Park (this );
27
- guard.release ()-> unlock ();
28
+ guard.Release ();
28
29
}
29
30
30
31
void Schedule () { stopped_fiber.Schedule (); }
31
32
32
33
private:
33
34
W* wg;
34
- Guard guard;
35
+ Guard& guard;
35
36
StoppedFiber stopped_fiber;
36
37
};
37
38
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ void WaitGroup::Done() {
38
38
void WaitGroup::Wait () {
39
39
Waiter::Guard guard (spinlock_);
40
40
if (counter_ > 0 ) {
41
- Waiter wg_waiter (this , std::move ( guard) );
41
+ Waiter wg_waiter (this , guard);
42
42
Suspend (&wg_waiter);
43
43
}
44
44
}
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/wait_group_awaiter.h>
12
13
13
14
namespace NFibers {
14
15
15
16
class WaitGroup {
16
- using Spinlock = NSync::SpinLock ;
17
+ using Spinlock = NSync::QueueSpinLock ;
17
18
using Waiter = WaitGroupWaiter<WaitGroup>;
18
19
19
20
friend Waiter;
You can’t perform that action at this time.
0 commit comments