Skip to content

Commit

Permalink
docs: add new snippet to README for wait_for_tasks()
Browse files Browse the repository at this point in the history
  • Loading branch information
DeveloperPaul123 committed Apr 26, 2024
1 parent e2b76cb commit dcf09b5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,21 @@ auto result = pool.enqueue([](int value) -> int { /*...your task...*/ return val
auto value = result.get();
```

Enqueue tasks and wait for them to complete:

```cpp
dp::thread_pool pool(4);

// add tasks, in this case without caring about results of individual tasks
pool.enqueue_detach([](int value) { /*...your task...*/ }, 34);
pool.enqueue_detach([](int value) { /*...your task...*/ }, 37);
pool.enqueue_detach([](int value) { /*...your task...*/ }, 38);
pool.enqueue_detach([](int value) { /*...your task...*/ }, 40);

// wait for all tasks to complete
pool.wait_for_tasks();
```
You can see other examples in the `/examples` folder.
## Benchmarks
Expand Down

0 comments on commit dcf09b5

Please sign in to comment.