Use pool for MultiValue container

This commit is contained in:
Alex Orlenko
2024-08-05 21:34:51 +01:00
parent ac6a391426
commit aa47324ee9
6 changed files with 45 additions and 73 deletions
+1 -6
View File
@@ -1,10 +1,9 @@
use std::any::TypeId;
use std::cell::UnsafeCell;
use std::rc::Rc;
// use std::collections::VecDeque;
use std::mem::{self, MaybeUninit};
use std::os::raw::{c_int, c_void};
use std::ptr;
use std::rc::Rc;
use std::sync::Arc;
use parking_lot::Mutex;
@@ -28,7 +27,6 @@ use super::{Lua, WeakLua};
static EXTRA_REGISTRY_KEY: u8 = 0;
const WRAPPED_FAILURE_POOL_SIZE: usize = 64;
// const MULTIVALUE_POOL_SIZE: usize = 64;
const REF_STACK_RESERVE: c_int = 1;
/// Data associated with the Lua state.
@@ -61,8 +59,6 @@ pub(crate) struct ExtraData {
// Pool of `WrappedFailure` enums in the ref thread (as userdata)
pub(super) wrapped_failure_pool: Vec<c_int>,
// Pool of `MultiValue` containers
// multivalue_pool: Vec<VecDeque<Value>>,
// Pool of `Thread`s (coroutines) for async execution
#[cfg(feature = "async")]
pub(super) thread_pool: Vec<c_int>,
@@ -162,7 +158,6 @@ impl ExtraData {
ref_stack_top: ffi::lua_gettop(ref_thread),
ref_free: Vec::new(),
wrapped_failure_pool: Vec::with_capacity(WRAPPED_FAILURE_POOL_SIZE),
// multivalue_pool: Vec::with_capacity(MULTIVALUE_POOL_SIZE),
#[cfg(feature = "async")]
thread_pool: Vec::new(),
wrapped_failure_mt_ptr,
-19
View File
@@ -496,25 +496,6 @@ impl RawLua {
false
}
// FIXME
// #[inline]
// pub(crate) fn pop_multivalue_from_pool(&self) -> Option<VecDeque<Value>> {
// let extra = unsafe { &mut *self.extra.get() };
// extra.multivalue_pool.pop()
// }
// FIXME
// #[inline]
// pub(crate) fn push_multivalue_to_pool(&self, mut multivalue: VecDeque<Value>) {
// let extra = unsafe { &mut *self.extra.get() };
// if extra.multivalue_pool.len() < MULTIVALUE_POOL_SIZE {
// multivalue.clear();
// extra
// .multivalue_pool
// .push(unsafe { mem::transmute(multivalue) });
// }
// }
/// Pushes a value that implements `IntoLua` onto the Lua stack.
///
/// Uses 2 stack spaces, does not call checkstack.
-1
View File
@@ -8,7 +8,6 @@ use crate::state::{ExtraData, RawLua};
use crate::util::{self, get_internal_metatable, WrappedFailure};
const WRAPPED_FAILURE_POOL_SIZE: usize = 64;
// const MULTIVALUE_POOL_SIZE: usize = 64;
pub(super) struct StateGuard<'a>(&'a RawLua, *mut ffi::lua_State);