Skip to main content

reifydb_runtime/pool/
mod.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2025 ReifyDB
3
4//! Thread-pool abstraction. Splits work across three named pools - async I/O, system, and query - so the runtime
5//! can size each independently. Native targets get the tokio-backed implementation; single-threaded and DST targets
6//! get the in-memory variant. The `Pools` type both impls hand back is what `SharedRuntime` carries around.
7
8#[cfg(all(not(reifydb_single_threaded), not(reifydb_target = "dst")))]
9mod native;
10
11#[cfg(any(reifydb_single_threaded, reifydb_target = "dst"))]
12mod wasm;
13
14#[cfg(all(not(reifydb_single_threaded), not(reifydb_target = "dst")))]
15pub use native::Pools;
16#[cfg(any(reifydb_single_threaded, reifydb_target = "dst"))]
17pub use wasm::Pools;
18
19#[derive(Debug, Clone)]
20pub struct PoolConfig {
21	pub system_threads: usize,
22
23	pub query_threads: usize,
24
25	pub async_threads: usize,
26}
27
28impl Default for PoolConfig {
29	fn default() -> Self {
30		Self {
31			async_threads: 1,
32			system_threads: 2,
33			query_threads: 1,
34		}
35	}
36}
37
38impl PoolConfig {
39	pub fn sync_only() -> Self {
40		Self {
41			async_threads: 0,
42			system_threads: 1,
43			query_threads: 1,
44		}
45	}
46}