@@ -60,6 +60,78 @@ executor.tick(DELTA, Some(1));
60
60
assert_eq! (executor . num_tasks (), 0 );
61
61
```
62
62
63
+ # Features
64
+
65
+ - ` tick_event `
66
+ - ` timer_registration `
67
+
68
+ ## Tick Registration
69
+
70
+ ``` rust
71
+ #[cfg(feature = " timer_registration" )]
72
+ {
73
+ use ticked_async_executor :: * ;
74
+
75
+ const DELTA : f64 = 1000.0 / 60.0 ;
76
+
77
+ let mut executor = TickedAsyncExecutor :: default ();
78
+
79
+ // These APIs are gated under the `timer_registration` feature
80
+ let timer = executor . create_timer_from_timer_registration ();
81
+
82
+ executor . spawn_local (" MyIdentifier1" , async move {
83
+ timer . sleep_for (10.0 ). await ;
84
+ }). detach ();
85
+
86
+ executor . wait_till_completed (1.0 );
87
+ assert_eq! (executor . num_tasks (), 0 );
88
+ }
89
+ ```
90
+
91
+ ## Tick Event
92
+
93
+ ``` rust
94
+ #[cfg(feature = " tick_event" )]
95
+ {
96
+ use ticked_async_executor :: * ;
97
+
98
+ const DELTA : f64 = 1000.0 / 60.0 ;
99
+
100
+ let mut executor = TickedAsyncExecutor :: default ();
101
+
102
+ // These APIs are gated under the `tick_event` feature
103
+ let _delta_tick_rx = executor . tick_channel ();
104
+ let timer = executor . create_timer_from_tick_event ();
105
+
106
+ executor . spawn_local (" MyIdentifier1" , async move {
107
+ timer . sleep_for (10.0 ). await ;
108
+ }). detach ();
109
+
110
+ executor . wait_till_completed (1.0 );
111
+ assert_eq! (executor . num_tasks (), 0 );
112
+ }
113
+ ```
114
+
115
+ # Benchmarks
116
+
117
+ - ` executor.spawn_local `
118
+ ``` text
119
+ Spawn 10000 tasks
120
+ time: [1.3711 ms 1.3713 ms 1.3715 ms]
121
+ ```
122
+
123
+ - ` executor.create_timer_from_timer_registration ` under feature ` timer_registration `
124
+ ``` text
125
+ Spawn 1000 timers from timer registration
126
+ time: [336.10 µs 336.42 µs 336.93 µs]
127
+ ```
128
+
129
+ - ` executor.create_timer_from_tick_event ` under feature ` tick_event `
130
+ ``` text
131
+ Spawn 1000 timers from tick event
132
+ time: [1.5688 ms 1.5692 ms 1.5697 ms]
133
+ ```
134
+
63
135
# Caveats
64
136
65
137
- Uses the ` smol ` ecosystem
0 commit comments