Hello π
I have a question: from the spawn_local docs it is said that
pub fn spawn_local<T>(future: impl Future<Output = T> + 'static) -> Task<T> β
where
T: 'static,
---
Spawns a task onto the current single-threaded executor.
If called from a `LocalExecutor`, the task is spawned on it. Otherwise, this method panics.
...
And the implementation basically just delegates the call into a LOCAL_EX executor spawn() method
pub fn spawn_local<T>(&self, future: impl Future<Output = T> + 'static) -> Task<T>
where
T: 'static,
{
#[cfg(not(feature = "native-tls"))]
return LOCAL_EX.with(|local_ex| Task::<T>(local_ex.spawn(future)));
#[cfg(feature = "native-tls")]
return Task::<T>(unsafe {
LOCAL_EX
.as_ref()
.expect("this thread doesn't have a LocalExecutor running")
.spawn(future)
});
}
Would it be ok if that spawn() method on LocalExecutor struct just be made pub? So if the caller already have the LocalExecutor instance then they can just use it without any panic-risk (even though it would essentially never happens)
Hello π
I have a question: from the
spawn_localdocs it is said thatAnd the implementation basically just delegates the call into a
LOCAL_EXexecutorspawn()methodWould it be ok if that
spawn()method onLocalExecutorstruct just be madepub? So if the caller already have theLocalExecutorinstance then they can just use it without any panic-risk (even though it would essentially never happens)