diff options
author | Alex Orlenko <zxteam@protonmail.com> | 2023-08-03 00:56:17 +0100 |
---|---|---|
committer | Alex Orlenko <zxteam@protonmail.com> | 2023-08-03 00:56:17 +0100 |
commit | cd0c8a4584401a68dc1141fe3b654eb647be27d0 (patch) | |
tree | 8045cda444dfdec6c898f563ae14a146960ea7d3 /src/util | |
parent | 4fff14a14467c5cd95f85d5e6980e808ab82cffd (diff) | |
download | mlua-cd0c8a4584401a68dc1141fe3b654eb647be27d0.zip |
Optimize async functionality:
Rewrite using the new `push_into_stack()`/`from_stack()` methods.
Also store thread state (pointer) in `Thread` struct to avoid getting it every time.
Async userdata methods still need to have arguments stored in ref thread as stack is empty on every poll().
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/mod.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/util/mod.rs b/src/util/mod.rs index d52119f..1351fbf 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -63,6 +63,11 @@ impl StackGuard { top: ffi::lua_gettop(state), } } + + // Same as `new()`, but allows specifying the expected stack size at the end of the scope. + pub const fn with_top(state: *mut ffi::lua_State, top: c_int) -> StackGuard { + StackGuard { state, top } + } } impl Drop for StackGuard { |