File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,9 +66,10 @@ class WFFacilities
6666 WaitGroup (int n);
6767 ~WaitGroup ();
6868
69- void done ();
7069 void wait () const ;
7170 std::future_status wait (int timeout) const ;
71+ void add (int n);
72+ void done ();
7273
7374 private:
7475 static void __wait_group_callback (WFCounterTask *task);
Original file line number Diff line number Diff line change @@ -192,14 +192,6 @@ inline WFFacilities::WaitGroup::~WaitGroup()
192192 this ->task ->count ();
193193}
194194
195- inline void WFFacilities::WaitGroup::done ()
196- {
197- if (--this ->nleft == 0 )
198- {
199- this ->task ->count ();
200- }
201- }
202-
203195inline void WFFacilities::WaitGroup::wait () const
204196{
205197 if (this ->nleft < 0 )
@@ -222,6 +214,19 @@ inline std::future_status WFFacilities::WaitGroup::wait(int timeout) const
222214 return this ->future .wait_for (std::chrono::milliseconds (timeout));
223215}
224216
217+ inline void WFFacilities::WaitGroup::add (int n)
218+ {
219+ if ((this ->nleft += n) == 0 )
220+ {
221+ this ->task ->count ();
222+ }
223+ }
224+
225+ inline void WFFacilities::WaitGroup::done ()
226+ {
227+ this ->add (-1 );
228+ }
229+
225230inline void WFFacilities::WaitGroup::__wait_group_callback (WFCounterTask *task)
226231{
227232 auto *pr = static_cast <WFPromise<void > *>(task->user_data );
You can’t perform that action at this time.
0 commit comments