Update docs
This commit is contained in:
1 parent
df39dd80b9
commit
f4160d2387
13 files changed
+106
-197
No files matched your search
@@ -16,16 +16,22 @@ async fn test_spawner_actually_spawns_tasks() -> DagResult<()> {
|
||||
|
||||
// Create 10 independent tasks
|
||||
let tasks: Vec<_> = (0..10)
|
||||
.map(|i| dag.add_task(task_fn(move |_: ()| async move { i })))
|
||||
.map(|i| {
|
||||
dag.add_task(task_fn({
|
||||
let value = spawn_count.clone();
|
||||
move |_: ()| {
|
||||
let value = value.clone();
|
||||
async move {
|
||||
value.fetch_add(1, Ordering::SeqCst);
|
||||
i
|
||||
}
|
||||
}
|
||||
}))
|
||||
})
|
||||
.collect();
|
||||
|
||||
// Custom spawner that counts invocations
|
||||
let counter = spawn_count.clone();
|
||||
dag.run(move |fut| {
|
||||
counter.fetch_add(1, Ordering::SeqCst);
|
||||
tokio::spawn(fut);
|
||||
})
|
||||
.await?;
|
||||
dag.run().await?;
|
||||
|
||||
// Verify all tasks were spawned
|
||||
for (i, task) in tasks.iter().enumerate() {
|
||||
|
||||
Reference in new issue
Block a user