Skip to content
Discussion options

You must be logged in to vote

Before writing a custom pool, check whether your build has bevy's multi_threaded feature. If it doesn't, both of your observations follow directly, and a hand-rolled pool would run into the same thing.

Without that feature bevy_tasks compiles single_threaded_task_pool.rs, where spawn is not what the name suggests:

pub fn spawn<T>(&self, future: ...) -> Task<T> {
    LOCAL_EXECUTOR.with(|executor| {
        let task = executor.spawn(future);
        // Loop until all tasks are done
        while executor.try_tick() {}
        task
    })
}

pub fn spawn_local<T>(&self, future: ...) -> Task<T> {
    self.spawn(future)
}

Everything lands on a thread-local executor, and after the spawning cal…

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
2 replies
@rohel01
Comment options

@SkiFire13
Comment options

Comment options

You must be logged in to vote
1 reply
@rohel01
Comment options

Comment options

You must be logged in to vote
2 replies
@rohel01
Comment options

@rohel01
Comment options

Answer selected by rohel01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants