From ecfcd96e4d981d35c22e3dbd7b42f070e4e424cb Mon Sep 17 00:00:00 2001 From: facebook-github-bot Date: Fri, 10 Nov 2023 00:54:55 +0000 Subject: [PATCH] deploy: 775d365992826c53ee1a5eec373338b281dd180e --- schedulable_8h.html | 2 +- schedulable_8h_source.html | 49 +++++++++++++++++++++----------------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/schedulable_8h.html b/schedulable_8h.html index 82a00c9..596123f 100644 --- a/schedulable_8h.html +++ b/schedulable_8h.html @@ -170,7 +170,7 @@

-

Definition at line 117 of file schedulable.h.

+

Definition at line 122 of file schedulable.h.

diff --git a/schedulable_8h_source.html b/schedulable_8h_source.html index 000c132..78822ea 100644 --- a/schedulable_8h_source.html +++ b/schedulable_8h_source.html @@ -151,30 +151,35 @@
93 // thread could be launched, and the process already is exiting when the thread is executing.
94 // Because it was after shutdown, backing memory for things could be no longer available.
95 struct ThreadWaiter {
-
96 detail::CompletionEventImpl impl_{0};
-
97
-
98 void add() {
-
99 impl_.intrusiveStatus().fetch_add(1, std::memory_order_acq_rel);
-
100 }
-
101
-
102 void remove() {
-
103 if (impl_.intrusiveStatus().fetch_sub(1, std::memory_order_acq_rel) == 1) {
-
104 impl_.notify(0);
-
105 }
-
106 }
-
107
-
108 ~ThreadWaiter() {
-
109 impl_.wait(0);
+
96 int count_ = 0;
+
97 std::mutex mtx_;
+
98 std::condition_variable cond_;
+
99
+
100 void add() {
+
101 std::lock_guard<std::mutex> lk(mtx_);
+
102 ++count_;
+
103 }
+
104
+
105 void remove() {
+
106 std::lock_guard<std::mutex> lk(mtx_);
+
107 if (--count_ == 0) {
+
108 cond_.notify_one();
+
109 }
110 }
-
111 };
-
112 DISPENSO_DLL_ACCESS static ThreadWaiter* getWaiter();
-
113
-
114 static void destroyThreadWaiter();
-
115};
-
116
-
117constexpr NewThreadInvoker kNewThreadInvoker;
+
111
+
112 ~ThreadWaiter() {
+
113 std::unique_lock<std::mutex> lk(mtx_);
+
114 cond_.wait(lk, [this]() { return count_ == 0; });
+
115 }
+
116 };
+
117 DISPENSO_DLL_ACCESS static ThreadWaiter* getWaiter();
118
-
119} // namespace dispenso
+
119 static void destroyThreadWaiter();
+
120};
+
121
+
122constexpr NewThreadInvoker kNewThreadInvoker;
+
123
+
124} // namespace dispenso
void schedule(F &&f) const
Definition: schedulable.h:37
void schedule(F &&f, ForceQueuingTag) const
Definition: schedulable.h:47