-
-
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
Expose after_start
and before_stop
in runtime::Builder
#756
Conversation
Hmm the test failure looks like another error, maybe restarting the job could solve it? |
So I can't restart AppVeyor runs myself, unfortunately, but had a question: any reason you opted to create a new mechanism for this instead of threading through to |
@bkchr do before and after hooks work for you? Those are more conservative and would be easier to add. |
@carllerche I tested another solution and that should work with |
@bkchr That would be a good solution as long as no tokio-threadpool API (types) leak out. The goal is to be able to bump the version of tokio-threadpool internally w/o a breaking change. |
around_thread
to the runtime::Builder
after_start
and before_stop
in runtime::Builder
@carllerche I updated the pr to expose |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs and a test 👍 Looks great to me.
This new function is called by tokio around each thread that is started.
This functionality is useful, when the user needs to setup certain
conditions for each new thread.
Motivation
Hey, I require to setup each thread that is started by tokio. In my case I want to call to Java and that requires that a thread is attached to the JVM. By using the new
around_thread
function, I'm able to setup each thread easily.Solution
Added a function to
runtime::Builder
. The function accepts a closure that will be given another closure that represents the thread. The outer closure is required to call the inner closure, otherwise the thread would not do any work.