Don't clone function when doing call_async()
This commit is contained in:
parent
c1168d3ec1
commit
1367a033d7
|
@ -1628,6 +1628,13 @@ impl Lua {
|
||||||
///
|
///
|
||||||
/// Equivalent to `coroutine.create`.
|
/// Equivalent to `coroutine.create`.
|
||||||
pub fn create_thread<'lua>(&'lua self, func: Function) -> Result<Thread<'lua>> {
|
pub fn create_thread<'lua>(&'lua self, func: Function) -> Result<Thread<'lua>> {
|
||||||
|
self.create_thread_inner(&func)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Wraps a Lua function into a new thread (or coroutine).
|
||||||
|
///
|
||||||
|
/// Takes function by reference.
|
||||||
|
fn create_thread_inner<'lua>(&'lua self, func: &Function) -> Result<Thread<'lua>> {
|
||||||
let state = self.state();
|
let state = self.state();
|
||||||
unsafe {
|
unsafe {
|
||||||
let _sg = StackGuard::new(state);
|
let _sg = StackGuard::new(state);
|
||||||
|
@ -1676,7 +1683,7 @@ impl Lua {
|
||||||
return Ok(Thread(LuaRef::new(self, index)));
|
return Ok(Thread(LuaRef::new(self, index)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
self.create_thread(func.clone())
|
self.create_thread_inner(func)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resets thread (coroutine) and returns to the pool for later use.
|
/// Resets thread (coroutine) and returns to the pool for later use.
|
||||||
|
|
Loading…
Reference in New Issue