-
Notifications
You must be signed in to change notification settings - Fork 13.3k
document task scheduler #3441
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
Comments
As far as your last question, there's no code to support this pattern yet, but the basic way to deal with this is to have the blocking task send spawn requests back to another task on the original scheduler. |
Some usage examples would certainly be handy, but this particular case is not hard. As best I can tell the blocking thread should be started with either SingleThreaded (if it spends most if its time blocked) or ManualThreads(1) (if it does substantial amounts of work between blocking). When the blocking thread needs to spawn off new tasks it simply uses spawn_sched(ThreadPerCore) which will cause those tasks to share the default threads. |
|
I'm still hoping to get a full task tutorial in for 0.4 and improve the rustdocs. |
I think I understand how it's supposed to work now. Bit painful to spin up a task just to create sub-tasks elsewhere within the right scheduler. Also quite error prone and will require that I touch lots of code. I think the answer in my case is to just use ManualThreads(small n) when I kick off a task to handle a new client connection. When that task needs to spawn sub-tasks it can just use task::spawn. More threads than I'd like but it's simple and should work reasonably well. |
Task tutorial now exists. |
Nominating for milestone 4, well-covered (if there is still work to do on this). |
accepted for well-covered milestone |
I think this is suitably covered by the task tutorial; if not, it needs to be more specific about what docs are required (beyond "more always"; that's not specific enough to be a bug since it'll never close). Meanwhile, closing this. |
implement for const generics
shims/unix: split general FD management from FS access `fd.rs` was a mix of general file descriptor infrastructure and file system access. Split those things up properly. Also add a `socket.rs` file where support for sockets can go eventually. For now it just contains the socketpair stub.
task.rs is a bit overwhelming and very difficult to understand how to use correctly. I think it would be helpful to document a bit better the theory of operation, the default scheduling mode, and probably even some examples for common tasks (even if its just pointers to suitable unit tests).
For example just how are users supposed to deal with foreign code that blocks? In the simple case I guess SingleThreaded would do the trick. But what about more complex cases? What if I need to call a foreign blocking function, wait for it to respond, and then kick off a bunch of concurrent tasks? Is there a way to spawn that task with SingleThreaded without changing the scheduling of its child tasks?
The text was updated successfully, but these errors were encountered: