pub fn async_timer(task: CTimerCB, interval: u64) -> CTimerResult
Expand description
Creates a repeating CTimerCB on the specified interval (in milliseconds). The task is completed when the CTimerResult::stop is called.
Example:
fn timer_cb() {
println!("Hello");
}
let timer_task = codemelted::async_timer( timer_cb, 250);
codemelted::async_sleep(100);
assert!(timer_task.is_running());
codemelted::async_sleep(1000);
timer_task.stop();
assert!(!timer_task.is_running());
--- title: Async Use Case Object Hierarchy --- classDiagram direction LR namespace codemelted { class CProtocolHandler { +id() String +is_running() bool +get_message() Result +post_message(T) Result +terminate() } class CTaskCB { +fn(Option) Option } class CTaskResult { +has_completed() bool +value() Option } class CTimerCB { +fn() } class CTimerResult { +has_completed() bool +stop() } class CWorkerCB { +fn(T) T } class CWorkerProtocol class async_task class async_timer class async_worker } namespace std { class thread } CTaskResult --> CTaskCB: calls CTaskResult --> thread: uses CTimerResult --> CTimerCB: calls CTimerResult --> thread: uses CWorkerProtocol --> CWorkerCB: calls CWorkerProtocol --> CProtocolHandler: implements CWorkerProtocol --> thread: uses async_task --> CTaskResult: creates async_timer --> CTimerResult: creates async_worker --> CWorkerProtocol: creates