Skip to content

Commit

Permalink
Update about-timer.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Barenboim authored Sep 24, 2024
1 parent 774d687 commit 9420446
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/en/about-timer.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ public:
time_t seconds, long nanoseconds,
timer_callback_t callback);

static void cancel_by_name(const std::string& timer_name)
static int cancel_by_name(const std::string& timer_name)
{
cancel_by_name(const std::string& timer_name, (size_t)-1);
}

static void cancel_by_name(const std::string& timer_name, size_t max);
static int cancel_by_name(const std::string& timer_name, size_t max);
};
~~~
We specify the timing time of a timer through the seconds and nanoseconds parameters. Among them, the value range of nanoseconds is [0,1000000000). When creating a timer, a timer_name can be specified. And we may interrupt a timer by calling **cancel_by_name** with this name later.
As a standard workflow task, there is also a user\_data field in the timer task that can be used to transfer some user data. Its starting method is the same as other tasks, and the procedure for adding it into the workflow is also the same.
# Canceling a timer
A named timer can be interrupted throught WFTaskFacotry::cancel_by_name interface, which will cancel all timers under the name by default. So we provide another cancel interface with the second argument **max** for user to cancel at most **max** timers. And of course, if no timer under the name, nothing performed.
A named timer can be interrupted throught WFTaskFacotry::cancel_by_name interface, which will cancel all timers under the name by default. So we provide another cancel interface with the second argument **max** for user to cancel at most **max** timers. Each interface returns the number of timers that was actually canceled. And of course, if no timer under the name, nothing performed and returns 0.
You can cancel a timer right after it's created, for example:
~~~cpp
#include <stdio.h>
Expand Down

0 comments on commit 9420446

Please sign in to comment.