Skip to main content

reifydb_runtime/pool/
mod.rs

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