-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add on_spawn
configuration for Builder
#3181
Comments
As a downside, such an |
Also I'd like similar |
@MikailBag In my use cases I'm adding some code to each poll so that indirection is required. If there are other use cases which would only run some code on each spawn, but not on each poll, then non-wrapping callback would be better. Perhaps that could be called |
This change implements two hooks for per-task actions, one which is invoked on task spawn, and one which is invoked during task termination. These hooks initially are only supplied with the task ID (on unstable only), but more information can be added in the future, as the struct used to supply parameters is opaque. Fixes #3181.
This change implements two hooks for per-task actions, one which is invoked on task spawn, and one which is invoked during task termination. These hooks initially are only supplied with the task ID (on unstable only), but more information can be added in the future, as the struct used to supply parameters is opaque. Fixes #3181.
This change implements two hooks for per-task actions, one which is invoked on task spawn, and one which is invoked during task termination. These hooks initially are only supplied with the task ID (on unstable only), but more information can be added in the future, as the struct used to supply parameters is opaque. Fixes #3181.
This change implements two hooks for per-task actions, one which is invoked on task spawn, and one which is invoked during task termination. These hooks initially are only supplied with the task ID (on unstable only), but more information can be added in the future, as the struct used to supply parameters is opaque. Fixes #3181.
Is your feature request related to a problem? Please describe.
For monitoring and tracking purposes I want to run some custom code when any spawned task is created/polled/dropped.
Describe the solution you'd like
I propose a configuration method
on_spawn
forBuilder
which would take a wrapper function to be applied to all spawned tasks.For example following two examples would be equivalent:
(First example in playground, with example Wrapper)
Describe alternatives you've considered
Alternative solution would be to apply this wrapper in all places where task is spawned. While this is possible for my own code, and also for crates like
Hyper
which offer configuration option likewith_executor
, this is not possible when using crates which do not offer such configuration option.Doing this configuration for tokio runtime would be much better option.
The text was updated successfully, but these errors were encountered: