bevy
bevy copied to clipboard
Add thread create/destroy callbacks to TaskPool
Objective
Fix #1991. Allow users to have a bit more control over the creation and finalization of the threads in TaskPool.
Solution
Add new methods to TaskPoolBuilder that expose callbacks that are called to initialize and finalize each thread in the TaskPool.
Unlike the proposed solution in #1991, the callback is argument-less. If an an identifier is needed, std::thread::current should provide that information easily.
Added a unit test to ensure that they're being called correctly.
made a some minor comments on the test. Would be willing to approve without any changes
bors r+
bors retry
Pull request successfully merged into main.
Build succeeded:
- build-and-install-on-iOS
- build-android
- build (macos-latest)
- build (ubuntu-latest)
- build-wasm
- build (windows-latest)
- build-without-default-features (bevy)
- build-without-default-features (bevy_ecs)
- build-without-default-features (bevy_reflect)
- check-compiles
- check-doc
- check-missing-examples-in-docs
- ci
- markdownlint
- run-examples
- run-examples-on-wasm
- run-examples-on-windows-dx12