-
Notifications
You must be signed in to change notification settings - Fork 501
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
Is it possible to spawn task to be executed in specific thread? #1199
Comments
Do you really want any specific thread, or usually just the current thread? If it's the latter and that's blocking like |
No, I want any specific thread. The reason why I want to do it this way instead of, e.g. execute non-sync parts on main thread and all other code in rayon, because I found out that if I put main event loop of a game into rayon threadpool, there is less jitter in FPS. Probably because time for waking main thread after finishing rayon tasks may vary wildly, and then there is need to wake rayon threads after starting new frame and submitting new tasks. When I run my main gameplay loop inside rayon thread pool, there is always at least one thread that never really blocks and keep working on tasks. P.S. And I also want to have this thread-specific tasks to have bigger priority to normal tasks, because normal tasks can be stolen and executed by other threads while those are limited to one. |
Ok, and do you want to block (with work stealing) to wait for a return value like
Regarding the latency from the main thread, note that you can also make that act as part of the pool with
That would be different than the current broadcasts, which are currently checked between local queue exhaustion and remote work stealing. Note that even if we add a new higher-priority queue that goes before normal tasks, we don't have any means of interrupting anything that's already executing, like an OS scheduler would with preemption. If you have that kind of need, it would probably be better to use dedicated threads outside of the pool. |
I personally want
Well, it was something that nice to have but not crucial. |
I want to have something like
broadcast
but which allows to execute a task in a specific thread, using result ofrayon::current_thread_index
as a selector.Context: it would allows to access something like
bevy_ecs::NonSend
soundly while running event loop entirely inside rayon threadpool.The text was updated successfully, but these errors were encountered: