-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Thread creation/destruction callbacks for TaskPool #1991
Copy link
Copy link
Closed
Labels
C-FeatureA new feature, making something new possibleA new feature, making something new possible
Description
What problem does this solve or what need does it fill?
I'd like to be able to run something on each created thread in a TaskPool after it's spawned and before it's destroyed. This would be useful for instrumentation purposes, profilers.
What solution would you like?
I propose adding two new boxed function fields in TaskPoolBuilder to define these operations.
TaskPoolBuilder::new()
.num_threads(N)
.thread_name("MyWorker")
.on_thread_spawn(|ix| { /* executes during build() on each worker */ })
.on_thread_destroy(|ix| { /* ... */ })
.build()What alternative(s) have you considered?
I considered spawning dummy tasks right after creating a TaskPool, but I don't expect to get a stable, round-robin order with each spawned task.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-FeatureA new feature, making something new possibleA new feature, making something new possible