@@ -161,7 +161,7 @@ static class __NamedTimerMap
161161 timer_callback_t && cb);
162162
163163public:
164- void cancel (const std::string& name, size_t max);
164+ int cancel (const std::string& name, size_t max);
165165
166166private:
167167 struct rb_root root_;
@@ -272,10 +272,11 @@ WFTimerTask *__NamedTimerMap::create(const std::string& name,
272272 return task;
273273}
274274
275- void __NamedTimerMap::cancel (const std::string& name, size_t max)
275+ int __NamedTimerMap::cancel (const std::string& name, size_t max)
276276{
277277 struct __timer_node *node;
278278 TimerList *timers;
279+ int ret = 0 ;
279280
280281 mutex_.lock ();
281282 timers = __get_object_list<TimerList>(name, &root_, false );
@@ -296,6 +297,7 @@ void __NamedTimerMap::cancel(const std::string& name, size_t max)
296297
297298 node->task = NULL ;
298299 max--;
300+ ret++;
299301 if (timers->empty ())
300302 {
301303 rb_erase (&timers->rb , &root_);
@@ -306,6 +308,7 @@ void __NamedTimerMap::cancel(const std::string& name, size_t max)
306308
307309 mutex_.unlock ();
308310 delete timers;
311+ return ret;
309312}
310313
311314WFTimerTask *WFTaskFactory::create_timer_task (const std::string& name,
@@ -317,9 +320,9 @@ WFTimerTask *WFTaskFactory::create_timer_task(const std::string& name,
317320 std::move (callback));
318321}
319322
320- void WFTaskFactory::cancel_by_name (const std::string& name, size_t max)
323+ int WFTaskFactory::cancel_by_name (const std::string& name, size_t max)
321324{
322- __timer_map.cancel (name, max);
325+ return __timer_map.cancel (name, max);
323326}
324327
325328/* ***************** Named Counter ******************/
@@ -342,7 +345,7 @@ static class __NamedCounterMap
342345 WFCounterTask *create (const std::string& name, unsigned int target_value,
343346 counter_callback_t && cb);
344347
345- void count_n (const std::string& name, unsigned int n);
348+ int count_n (const std::string& name, unsigned int n);
346349 void count (CounterList *counters, struct __counter_node *node);
347350
348351 void remove (CounterList *counters, struct __counter_node *node)
@@ -444,12 +447,13 @@ bool __NamedCounterMap::count_n_locked(CounterList *counters, unsigned int n,
444447 return false ;
445448}
446449
447- void __NamedCounterMap::count_n (const std::string& name, unsigned int n)
450+ int __NamedCounterMap::count_n (const std::string& name, unsigned int n)
448451{
449452 LIST_HEAD (task_list);
450453 struct __counter_node *node;
451454 CounterList *counters;
452455 bool erased = false ;
456+ int ret = 0 ;
453457
454458 mutex_.lock ();
455459 counters = __get_object_list<CounterList>(name, &root_, false );
@@ -465,7 +469,10 @@ void __NamedCounterMap::count_n(const std::string& name, unsigned int n)
465469 node = list_entry (task_list.next , struct __counter_node , list);
466470 list_del (&node->list );
467471 node->task ->WFCounterTask ::count ();
472+ ret++;
468473 }
474+
475+ return ret;
469476}
470477
471478void __NamedCounterMap::count (CounterList *counters,
@@ -496,9 +503,9 @@ WFCounterTask *WFTaskFactory::create_counter_task(const std::string& name,
496503 return __counter_map.create (name, target_value, std::move (callback));
497504}
498505
499- void WFTaskFactory::count_by_name (const std::string& name, unsigned int n)
506+ int WFTaskFactory::count_by_name (const std::string& name, unsigned int n)
500507{
501- __counter_map.count_n (name, n);
508+ return __counter_map.count_n (name, n);
502509}
503510
504511/* ***************** Named Mailbox ******************/
@@ -521,7 +528,7 @@ static class __NamedMailboxMap
521528 mailbox_callback_t && cb);
522529 WFMailboxTask *create (const std::string& name, mailbox_callback_t && cb);
523530
524- void send (const std::string& name, void *msg, size_t max);
531+ int send (const std::string& name, void *msg, size_t max);
525532 void send (MailboxList *mailboxes, struct __mailbox_node *node, void *msg);
526533
527534 void remove (MailboxList *mailboxes, struct __mailbox_node *node)
@@ -628,12 +635,13 @@ bool __NamedMailboxMap::send_max_locked(MailboxList *mailboxes,
628635 return true ;
629636}
630637
631- void __NamedMailboxMap::send (const std::string& name, void *msg, size_t max)
638+ int __NamedMailboxMap::send (const std::string& name, void *msg, size_t max)
632639{
633640 LIST_HEAD (task_list);
634641 struct __mailbox_node *node;
635642 MailboxList *mailboxes;
636643 bool erased = false ;
644+ int ret = 0 ;
637645
638646 mutex_.lock ();
639647 mailboxes = __get_object_list<MailboxList>(name, &root_, false );
@@ -649,7 +657,10 @@ void __NamedMailboxMap::send(const std::string& name, void *msg, size_t max)
649657 node = list_entry (task_list.next , struct __mailbox_node , list);
650658 list_del (&node->list );
651659 node->task ->WFMailboxTask ::send (msg);
660+ ret++;
652661 }
662+
663+ return ret;
653664}
654665
655666void __NamedMailboxMap::send (MailboxList *mailboxes,
@@ -680,9 +691,9 @@ WFMailboxTask *WFTaskFactory::create_mailbox_task(const std::string& name,
680691 return __mailbox_map.create (name, std::move (callback));
681692}
682693
683- void WFTaskFactory::send_by_name (const std::string& name, void *msg, size_t max)
694+ int WFTaskFactory::send_by_name (const std::string& name, void *msg, size_t max)
684695{
685- __mailbox_map.send (name, msg, max);
696+ return __mailbox_map.send (name, msg, max);
686697}
687698
688699/* ***************** Named Conditional ******************/
@@ -705,7 +716,7 @@ static class __NamedConditionalMap
705716 void **msgbuf);
706717 WFConditional *create (const std::string& name, SubTask *task);
707718
708- void signal (const std::string& name, void *msg, size_t max);
719+ int signal (const std::string& name, void *msg, size_t max);
709720 void signal (ConditionalList *conds, struct __conditional_node *node,
710721 void *msg);
711722
@@ -812,12 +823,13 @@ bool __NamedConditionalMap::signal_max_locked(ConditionalList *conds,
812823 return true ;
813824}
814825
815- void __NamedConditionalMap::signal (const std::string& name, void *msg, size_t max)
826+ int __NamedConditionalMap::signal (const std::string& name, void *msg, size_t max)
816827{
817828 LIST_HEAD (cond_list);
818829 struct __conditional_node *node;
819830 ConditionalList *conds;
820831 bool erased = false ;
832+ int ret = 0 ;
821833
822834 mutex_.lock ();
823835 conds = __get_object_list<ConditionalList>(name, &root_, false );
@@ -833,7 +845,10 @@ void __NamedConditionalMap::signal(const std::string& name, void *msg, size_t ma
833845 node = list_entry (cond_list.next , struct __conditional_node , list);
834846 list_del (&node->list );
835847 node->cond ->WFConditional ::signal (msg);
848+ ret++;
836849 }
850+
851+ return ret;
837852}
838853
839854void __NamedConditionalMap::signal (ConditionalList *conds,
@@ -863,10 +878,10 @@ WFConditional *WFTaskFactory::create_conditional(const std::string& name,
863878 return __conditional_map.create (name, task);
864879}
865880
866- void WFTaskFactory::signal_by_name (const std::string& name, void *msg,
881+ int WFTaskFactory::signal_by_name (const std::string& name, void *msg,
867882 size_t max)
868883{
869- __conditional_map.signal (name, msg, max);
884+ return __conditional_map.signal (name, msg, max);
870885}
871886
872887/* ***************** Named Guard ******************/
0 commit comments