-
Notifications
You must be signed in to change notification settings - Fork 115
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
Consider providing fn to retrieve a Handle
for the currently running reactor Core
#79
Comments
Ok @carllerche, @aturon, and I talked about this at lunch today, and here are some of the thoughts we came up with:
In general we found it difficult to reason about a global event loop and we didn't make too much progress along that front in figuring out what to do. |
@alexcrichton I came to this after looking at hyperium/hyper#1075. I was wondering if there could be a default event loop in order to make setting up a hyper server easy without needing to make it own the core and event loop - i.e. make the three steps I mentioned in that ticket two: set up the protocol/event handlers and then start the default event loop. The way I'd imagine setting up event loops would be either a simple single threaded program with a single event loop, or a multi-threaded program with an event loop per thread: with event driven programming I generally expect the event loop to be running continuously for the duration of the program/process/thread (maybe this is because I've done a lot of JavaScript where all you have is the default event loop and there is no possibility of stopping it). If this makes sense, would it be possible to provide a way to get a thread local default core? Thanks Tom |
Thanks for the comment @tomyan! FWIW there's a comment which shows how to use Hyper with a custom In general though in tokio-core we're hoping to avoid having a global event loop as it brings quite a few complications along with it. I believe there's crates like tk-easyloop which aim to provide this sort of "global" and/or thread-local access to a local event loop, and maybe those would help? |
Thanks for the pointer, I hadn't realised I could actually use that code. I was working on a PR for a default core and handle based on the code in #203, so I've finished and submitted that. Understand from your comment that it's unlikely to be accepted, which is fine but thought I'd submit for consideration anyway: #212. Interested in what kind of complications this adds, since from my perspective it makes the common case a bit simpler. Happy either way though, since the comment you pointed me to unblocks me. Thanks Tom |
Ok! I'll take a look at the PR |
This will be useful feature, any idea when it will be done? |
This crate is deprecated in favor of http://github.com/tokio-rs/tokio. New features are no longer being added. This feature is also provided in the new crate. |
Something like:
The text was updated successfully, but these errors were encountered: