Avoid unnecessarily coping result inner value if it doesn't require ownership
This commit is contained in:
@@ -177,6 +177,15 @@ unsafe impl<F: Future<Output: IntoFfi> + 'static> IntoFfi for lua_future<F> {
|
||||
self
|
||||
}
|
||||
|
||||
fn require_owned() -> bool {
|
||||
// future always requires full ownership of itself even if it's a "temporary", because we
|
||||
// must yield a full cdata to the runtime not a cdata containing a pointer to the future. if
|
||||
// this is set to false, postlude might receive a reference lua_future cdata instead of a
|
||||
// full lua_future cdata, and the runtime might incorrectly read the pointer value as
|
||||
// lua_future itself (it does not dereference it).
|
||||
true
|
||||
}
|
||||
|
||||
fn postlude(ret: &str) -> impl Display {
|
||||
// When returning a future from Rust to Lua, yield it immediately to the runtime which will
|
||||
// poll it to completion in the background, then take the fulfilled value once the thread
|
||||
|
||||
Reference in New Issue
Block a user