File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,9 +68,10 @@ class WFFacilities
6868 WaitGroup (int n);
6969 ~WaitGroup ();
7070
71- void done ();
7271 void wait () const ;
7372 std::future_status wait (int timeout) const ;
73+ void add (int n);
74+ void done ();
7475
7576 private:
7677 static void __wait_group_callback (WFCounterTask *task);
Original file line number Diff line number Diff line change @@ -196,14 +196,6 @@ inline WFFacilities::WaitGroup::~WaitGroup()
196196 this ->task ->count ();
197197}
198198
199- inline void WFFacilities::WaitGroup::done ()
200- {
201- if (--this ->nleft == 0 )
202- {
203- this ->task ->count ();
204- }
205- }
206-
207199inline void WFFacilities::WaitGroup::wait () const
208200{
209201 if (this ->nleft < 0 )
@@ -226,6 +218,19 @@ inline std::future_status WFFacilities::WaitGroup::wait(int timeout) const
226218 return this ->future .wait_for (std::chrono::milliseconds (timeout));
227219}
228220
221+ inline void WFFacilities::WaitGroup::add (int n)
222+ {
223+ if ((this ->nleft += n) == 0 )
224+ {
225+ this ->task ->count ();
226+ }
227+ }
228+
229+ inline void WFFacilities::WaitGroup::done ()
230+ {
231+ this ->add (-1 );
232+ }
233+
229234inline void WFFacilities::WaitGroup::__wait_group_callback (WFCounterTask *task)
230235{
231236 auto *pr = static_cast <WFPromise<void > *>(task->user_data );
You can’t perform that action at this time.
0 commit comments