Trait gdnative_async::AsyncMethod
source · pub trait AsyncMethod<C: NativeClass>: Send + Sync + 'static {
fn spawn_with(&self, spawner: Spawner<'_, C>);
fn site() -> Option<Site<'static>> { ... }
}
Expand description
Trait for async methods. When exported, such methods return FunctionState
-like
objects that can be manually resumed or yielded to completion.
Async methods are always spawned locally on the thread where they were created,
and never sent to another thread. This is so that we can ensure the safety of
emitting signals from the FunctionState
-like object. If you need to off-load
some task to another thread, consider using something like
futures::future::Remote
to spawn it remotely on a thread pool.
Required Methods§
sourcefn spawn_with(&self, spawner: Spawner<'_, C>)
fn spawn_with(&self, spawner: Spawner<'_, C>)
Spawns the future for result of this method with spawner
. This is done so
that implementors of this trait do not have to name their future types.
If the spawner
object is not used, the Godot side of the call will fail, output an
error, and return a Nil
variant.