bevy/crates/bevy_tasks/src
Pixelstorm faa1b57de5
Global TaskPool API improvements (#10008)
# Objective

Reduce code duplication and improve APIs of Bevy's [global
taskpools](https://github.com/bevyengine/bevy/blob/main/crates/bevy_tasks/src/usages.rs).

## Solution

- As all three of the global taskpools have identical implementations
and only differ in their identifiers, this PR moves the implementation
into a macro to reduce code duplication.
- The `init` method is renamed to `get_or_init` to more accurately
reflect what it really does.
- Add a new `try_get` method that just returns `None` when the pool is
uninitialized, to complement the other getter methods.
- Minor documentation improvements to accompany the above changes.

---

## Changelog

- Added a new `try_get` method to the global TaskPools
- The global TaskPools' `init` method has been renamed to `get_or_init`
for clarity
- Documentation improvements

## Migration Guide

- Uses of `ComputeTaskPool::init`, `AsyncComputeTaskPool::init` and
`IoTaskPool::init` should be changed to `::get_or_init`.
2023-10-23 20:48:48 +00:00
..
iter small and mostly pointless refactoring (#2934) 2022-02-13 22:33:55 +00:00
lib.rs Allow using async_io::block_on in bevy_tasks (#9626) 2023-09-25 19:59:50 +00:00
single_threaded_task_pool.rs Multiple Asset Sources (#9885) 2023-10-13 23:17:32 +00:00
slice.rs Document bevy_tasks and enable #![warn(missing_docs)] (#3509) 2022-01-16 04:53:22 +00:00
task.rs Improve doc formatting. (#9840) 2023-09-18 19:43:56 +00:00
task_pool.rs add test for nested scopes (#10026) 2023-10-05 06:05:43 +00:00
thread_executor.rs fix clippy::default_constructed_unit_structs and trybuild errors (#9144) 2023-07-13 22:23:04 +00:00
usages.rs Global TaskPool API improvements (#10008) 2023-10-23 20:48:48 +00:00