-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Wrapping task_pool
for platform independent interface
#4346
Conversation
Alright, here's the situation. |
@MiniaczQ is there an issue to link to for that WASM tasks rework? |
Right here #4301 |
Given that #4466 is now merged, is this still blocked? |
Shouldn't be, I'll try to get a draft done today, just gonna reapply changes to a fresh main since it'll be quicker |
e5e1667
to
d3eeacc
Compare
Kudos to hymm, the refactor was very smooth 😃 |
Status for today:
|
Bevy-local fix to |
} | ||
self.0.scope(|s| { | ||
let scope = Scope(s); | ||
let scope_ref: &'env Scope<'_, 'env, T> = unsafe { mem::transmute(&scope) }; |
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.
I'm not an expert with unsafe Rust, but '_
probably creates an unbounded lifetime (See the unbounded lifetimes part). You should specify a lifetime for 'scope
in Scope
.
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.
Tested with <'scope, 'env, T>
, same SIGSEGV
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.
I posted this on discord, but will repost here so it doesn't get lost. The problem is that scope_ref only lives for the lifetime of the closure it's in, but needs to live until .scope
returns. I'm not sure how to get around this as it's important that the scope object is constructed inside the scope function, so that the 'scope
lifetime is only available inside the scope function. Basically this needs to be self.0.scope(f)
, but I'm not sure how you do that with the wrappers.
executor, | ||
results, | ||
scope: PhantomData, | ||
env: PhantomData, | ||
}; | ||
|
||
let scope_ref: &'env mut Scope<'_, 'env, T> = unsafe { mem::transmute(&mut scope) }; | ||
let scope_ref: &'env mut PlatformScope<'_, 'env, T> = unsafe { mem::transmute(&mut scope) }; |
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.
Same here.
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.
As you can see here this was only refactored by name, so that isn't an issue
Objective
As described in #4304
Solution
task_pool_wasm
andtask_pool_other
.task_pool
was made as the wrapper and only public interfaceIffy stuff
Scope
wrapper is used in platform specificTaskPool::scope
implementations to ensure user always sees user-sided typesTaskPool::spawn
andTaskPool::spawn_local
were replaced withTaskPool::spawn_local_detached
to normalize wasm and non-wasm interfaces without a major rework, while still satisfying the internal use cases