mirror of
https://github.com/sogou/workflow.git
synced 2026-10-29 03:27:04 +08:00
Enable to signal a maximum number of condtional.
This commit is contained in:
@@ -351,7 +351,7 @@ public:
|
||||
|
||||
WFConditional *create(const std::string& name, SubTask *task);
|
||||
|
||||
void signal(const std::string& name, void *msg);
|
||||
void signal(const std::string& name, void *msg, size_t max);
|
||||
void signal(struct __ConditionalList *conds,
|
||||
struct __conditional_node *node,
|
||||
void *msg);
|
||||
@@ -451,7 +451,7 @@ struct __ConditionalList *__ConditionalMap::get_list(const std::string& name)
|
||||
return conds;
|
||||
}
|
||||
|
||||
void __ConditionalMap::signal(const std::string& name, void *msg)
|
||||
void __ConditionalMap::signal(const std::string& name, void *msg, size_t max)
|
||||
{
|
||||
struct __ConditionalList *conds;
|
||||
struct rb_node *p;
|
||||
@@ -482,8 +482,12 @@ void __ConditionalMap::signal(const std::string& name, void *msg)
|
||||
|
||||
list_for_each_safe(pos, tmp, &conds->head)
|
||||
{
|
||||
if (max == 0)
|
||||
return;
|
||||
|
||||
node = list_entry(pos, struct __conditional_node, list);
|
||||
node->cond->WFConditional::signal(msg);
|
||||
max--;
|
||||
}
|
||||
|
||||
delete conds;
|
||||
@@ -531,9 +535,10 @@ WFConditional *WFTaskFactory::create_conditional(const std::string& cond_name,
|
||||
return __conditional_map.create(cond_name, task);
|
||||
}
|
||||
|
||||
void WFTaskFactory::signal_by_name(const std::string& cond_name, void *msg)
|
||||
void WFTaskFactory::signal_by_name(const std::string& cond_name, void *msg,
|
||||
size_t max)
|
||||
{
|
||||
__conditional_map.signal(cond_name, msg);
|
||||
__conditional_map.signal(cond_name, msg, max);
|
||||
}
|
||||
|
||||
/**************** Timed Go Task *****************/
|
||||
|
||||
@@ -284,7 +284,13 @@ public:
|
||||
static WFConditional *create_conditional(const std::string& cond_name,
|
||||
SubTask *task);
|
||||
|
||||
static void signal_by_name(const std::string& cond_name, void *msg);
|
||||
static void signal_by_name(const std::string& cond_name, void *msg)
|
||||
{
|
||||
WFTaskFactory::signal_by_name(cond_name, msg, (size_t)-1);
|
||||
}
|
||||
|
||||
static void signal_by_name(const std::string& cond_name, void *msg,
|
||||
size_t max);
|
||||
|
||||
public:
|
||||
template<class FUNC, class... ARGS>
|
||||
|
||||
Reference in New Issue
Block a user