diff options
author | Alex Orlenko <zxteam@protonmail.com> | 2023-03-03 18:29:04 +0000 |
---|---|---|
committer | Alex Orlenko <zxteam@protonmail.com> | 2023-03-03 18:29:04 +0000 |
commit | d7db1b7f2eff01eca1531760d28d8b28bb8054ac (patch) | |
tree | 37e34a9ee7fa9e72890703db1364c8b9b88a3d33 | |
parent | 22c973af02826dba3b6401b873589f44a0f3374e (diff) | |
download | mlua-d7db1b7f2eff01eca1531760d28d8b28bb8054ac.zip |
Add Waker lifetime to WakerGuard
-rw-r--r-- | src/thread.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/thread.rs b/src/thread.rs index 0894065..9294ffc 100644 --- a/src/thread.rs +++ b/src/thread.rs @@ -461,24 +461,29 @@ fn is_poll_pending(val: &MultiValue) -> bool { } #[cfg(feature = "async")] -struct WakerGuard<'lua> { +struct WakerGuard<'lua, 'a> { lua: &'lua Lua, prev: NonNull<Waker>, + _phantom: PhantomData<&'a ()>, } #[cfg(feature = "async")] -impl<'lua> WakerGuard<'lua> { +impl<'lua, 'a> WakerGuard<'lua, 'a> { #[inline] - pub fn new(lua: &'lua Lua, waker: &Waker) -> Result<WakerGuard<'lua>> { + pub fn new(lua: &'lua Lua, waker: &'a Waker) -> Result<WakerGuard<'lua, 'a>> { unsafe { let prev = lua.set_waker(NonNull::from(waker)); - Ok(WakerGuard { lua, prev }) + Ok(WakerGuard { + lua, + prev, + _phantom: PhantomData, + }) } } } #[cfg(feature = "async")] -impl<'lua> Drop for WakerGuard<'lua> { +impl<'lua, 'a> Drop for WakerGuard<'lua, 'a> { fn drop(&mut self) { unsafe { self.lua.set_waker(self.prev); |