pub struct SqlitePool { /* private fields */ }Expand description
A bounded pool of plain OS threads shared by every database of one runtime process. The pool spawns threads lazily, up to its cap, only when no thread is free. Cloning shares the pool; it shuts down once the owner and every database handle have dropped their clones.
Implementations§
Source§impl SqlitePool
impl SqlitePool
Sourcepub fn from_env(metrics: Option<Arc<dyn SqlitePoolMetrics>>) -> Self
pub fn from_env(metrics: Option<Arc<dyn SqlitePoolMetrics>>) -> Self
Reads the thread cap from RIVETKIT_SQLITE_WORKER_THREADS.
Sourcepub fn new(
max_threads: usize,
metrics: Option<Arc<dyn SqlitePoolMetrics>>,
) -> Self
pub fn new( max_threads: usize, metrics: Option<Arc<dyn SqlitePoolMetrics>>, ) -> Self
Starts no threads; the first database action spawns the first one.
Sourcepub fn page_budget(&self) -> &Arc<PageBudget> ⓘ
pub fn page_budget(&self) -> &Arc<PageBudget> ⓘ
The page budget every database on this pool shares.
Sourcepub fn request_allocator_trim(&self)
pub fn request_allocator_trim(&self)
Threads spawned so far, never more than the cap.
Returns freed native memory to the OS soon, on a pool thread, coalescing requests so
trims run at most once per ALLOCATOR_TRIM_INTERVAL. Call after releasing a database.
pub fn live_threads(&self) -> usize
pub fn max_threads(&self) -> usize
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for SqlitePool
impl !UnwindSafe for SqlitePool
impl Freeze for SqlitePool
impl Send for SqlitePool
impl Sync for SqlitePool
impl Unpin for SqlitePool
impl UnsafeUnpin for SqlitePool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more