summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorAlex Orlenko <zxteam@protonmail.com>2023-08-03 00:56:17 +0100
committerAlex Orlenko <zxteam@protonmail.com>2023-08-03 00:56:17 +0100
commitcd0c8a4584401a68dc1141fe3b654eb647be27d0 (patch)
tree8045cda444dfdec6c898f563ae14a146960ea7d3 /src/util
parent4fff14a14467c5cd95f85d5e6980e808ab82cffd (diff)
downloadmlua-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.rs5
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 {