Wrapping task_pool for platform independent interface#4346
Wrapping task_pool for platform independent interface#4346MiniaczQ wants to merge 5 commits intobevyengine:mainfrom
task_pool for platform independent interface#4346Conversation
|
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.
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.
Tested with <'scope, 'env, T>, same SIGSEGV
There was a problem hiding this comment.
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.
| }; | ||
|
|
||
| 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.
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_wasmandtask_pool_other.task_poolwas made as the wrapper and only public interfaceIffy stuff
Scopewrapper is used in platform specificTaskPool::scopeimplementations to ensure user always sees user-sided typesTaskPool::spawnandTaskPool::spawn_localwere replaced withTaskPool::spawn_local_detachedto normalize wasm and non-wasm interfaces without a major rework, while still satisfying the internal use cases