delay-timer
Time-manager of delayed tasks. Like crontab, but synchronous asynchronous tasks are possible, and dynamic add/cancel/remove is supported.
delay-timer is a task manager based on a time wheel algorithm, which makes it easy to manage timed tasks, or to periodically execute arbitrary tasks such as closures.
The underlying runtime is based on the optional smol and tokio, and you can build your application with either one.
The minimum-supported version of rustc
is 1.56.
Except for the simple execution in a few seconds, you can also specify a specific date, such as Sunday at 4am to execute a backup task.
Supports configuration of the maximum number of parallelism of tasks.
Dynamically cancel a running task instance by means of a handle.
If you're looking for a distributed task scheduling platform, check out the delicate
Examples
use Result;
use *;
Use in asynchronous contexts.
use *;
use Result;
use Timer;
use Duration;
async
Capture the specified environment information and build the closure & task:
use *;
use ;
use Arc;
let delay_timer = new;
let share_num = new;
let share_num_bunshin = share_num.clone;
let body = move || ;
let task = default
.set_frequency_count_down_by_cron_str
.set_task_id
.spawn_routine?;
delay_timer.add_task?;
Building customized-dynamic future tasks:
use *;
use ;
pub async
There's a lot more in the [examples] directory.
License
Licensed under either of
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
To Do List
- Support tokio Ecology.
- Disable unwrap related methods that will panic.
- Thread and running task quit when delayTimer drop.
- neaten todo in code, replenish tests and benchmark.
- batch-opration.
- report-for-server.
- Future upgrade of delay_timer to multi-wheel mode, different excutor handling different wheels e.g. subtract laps for one wheel, run task for one wheel.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.