Skip to content

Commit d36baaf

Browse files
committed
up mm
1 parent 2e3ae71 commit d36baaf

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

src/components/sync/queue_spinlock.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class QueueSpinLock final {
4242

4343
private:
4444
void Acquire(Guard* guard) {
45-
auto ancestor = tail_.exchange(guard, std::memory_order_acquire);
45+
auto ancestor = tail_.exchange(guard/*, std::memory_order_acquire*/);
4646
if (ancestor == nullptr) {
4747
guard->SetOwner();
4848
return;

src/fiber/awaiter/wait_group_awaiter.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <mutex>
88

99
#include <components/intrusive/list.h>
10+
#include <components/sync/queue_spinlock.h>
1011
#include <fiber/awaiter/awaiter.h>
1112

1213
namespace NFibers {
@@ -15,23 +16,23 @@ template <class W>
1516
class WaitGroupWaiter : public IAwaiter,
1617
public NComponents::Node<WaitGroupWaiter<W>> {
1718
public:
18-
using Guard = std::unique_lock<typename W::Spinlock>;
19+
using Guard = NSync::QueueSpinLock::Guard;
1920

20-
WaitGroupWaiter(W* wg, Guard guard) : wg(wg), guard(std::move(guard)){};
21+
WaitGroupWaiter(W* wg, Guard& guard) : wg(wg), guard(guard){};
2122

2223
void AwaitSuspend(StoppedFiber fiber) override {
2324
assert(fiber.IsValid());
2425

2526
stopped_fiber = fiber;
2627
wg->Park(this);
27-
guard.release()->unlock();
28+
guard.Release();
2829
}
2930

3031
void Schedule() { stopped_fiber.Schedule(); }
3132

3233
private:
3334
W* wg;
34-
Guard guard;
35+
Guard& guard;
3536
StoppedFiber stopped_fiber;
3637
};
3738

src/fiber/sync/wait_group.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void WaitGroup::Done() {
3838
void WaitGroup::Wait() {
3939
Waiter::Guard guard(spinlock_);
4040
if (counter_ > 0) {
41-
Waiter wg_waiter(this, std::move(guard));
41+
Waiter wg_waiter(this, guard);
4242
Suspend(&wg_waiter);
4343
}
4444
}

src/fiber/sync/wait_group.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88

99
#include <components/intrusive/list.h>
1010
#include <components/sync/spinLock.h>
11+
#include <components/sync/queue_spinlock.h>
1112
#include <fiber/awaiter/wait_group_awaiter.h>
1213

1314
namespace NFibers {
1415

1516
class WaitGroup {
16-
using Spinlock = NSync::SpinLock;
17+
using Spinlock = NSync::QueueSpinLock;
1718
using Waiter = WaitGroupWaiter<WaitGroup>;
1819

1920
friend Waiter;

0 commit comments

Comments
 (0)