Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,78 @@ executor.tick(DELTA, Some(1));
assert_eq!(executor.num_tasks(), 0);
```

# Features

- `tick_event`
- `timer_registration`

## Tick Registration

```rust
#[cfg(feature = "timer_registration")]
{
use ticked_async_executor::*;

const DELTA: f64 = 1000.0 / 60.0;

let mut executor = TickedAsyncExecutor::default();

// These APIs are gated under the `timer_registration` feature
let timer = executor.create_timer_from_timer_registration();

executor.spawn_local("MyIdentifier1", async move {
timer.sleep_for(10.0).await;
}).detach();

executor.wait_till_completed(1.0);
assert_eq!(executor.num_tasks(), 0);
}
```

## Tick Event

```rust
#[cfg(feature = "tick_event")]
{
use ticked_async_executor::*;

const DELTA: f64 = 1000.0 / 60.0;

let mut executor = TickedAsyncExecutor::default();

// These APIs are gated under the `tick_event` feature
let _delta_tick_rx = executor.tick_channel();
let timer = executor.create_timer_from_tick_event();

executor.spawn_local("MyIdentifier1", async move {
timer.sleep_for(10.0).await;
}).detach();

executor.wait_till_completed(1.0);
assert_eq!(executor.num_tasks(), 0);
}
```

# Benchmarks

- `executor.spawn_local`
```text
Spawn 10000 tasks
time: [1.3711 ms 1.3713 ms 1.3715 ms]
```

- `executor.create_timer_from_timer_registration` under feature `timer_registration`
```text
Spawn 1000 timers from timer registration
time: [336.10 µs 336.42 µs 336.93 µs]
```

- `executor.create_timer_from_tick_event` under feature `tick_event`
```text
Spawn 1000 timers from tick event
time: [1.5688 ms 1.5692 ms 1.5697 ms]
```

# Caveats

- Uses the `smol` ecosystem
Expand Down