orx_parallel/pools/
global_pool.rs1use crate::pools::pool_impl::*;
2#[cfg(feature = "std")]
3use std::sync::LazyLock;
4
5#[cfg(all(feature = "std", feature = "wasm", target_arch = "wasm32"))]
13static PERSISTENT_POOL: LazyLock<WasmWebPool> = LazyLock::new(Default::default);
14
15#[cfg(all(
17 feature = "std",
18 feature = "persistent-pool-rayon",
19 not(all(feature = "wasm", target_arch = "wasm32")),
20))]
21static PERSISTENT_POOL: LazyLock<rayon_core::ThreadPool> =
22 LazyLock::new(build_default_rayon_thread_pool);
23
24#[cfg(all(
26 feature = "std",
27 feature = "transient-pool",
28 not(all(feature = "wasm", target_arch = "wasm32")),
29 not(feature = "persistent-pool-rayon"),
30))]
31static PERSISTENT_POOL: LazyLock<OncePool> = LazyLock::new(Default::default);
32
33#[cfg(all(
35 feature = "std",
36 not(all(feature = "wasm", target_arch = "wasm32")),
37 not(feature = "persistent-pool-rayon"),
38 not(feature = "transient-pool"),
39))]
40static PERSISTENT_POOL: LazyLock<BasicPool> = LazyLock::new(Default::default);
41
42#[cfg(all(
44 not(feature = "std"),
45 not(all(feature = "wasm", target_arch = "wasm32")),
46 not(feature = "persistent-pool-rayon"),
47 not(feature = "transient-pool"),
48))]
49static PERSISTENT_POOL: SequentialPool = SequentialPool;
50
51#[cfg(all(feature = "std", feature = "wasm", target_arch = "wasm32"))]
55pub type DefaultPool = &'static WasmWebPool;
57
58#[cfg(all(
60 feature = "std",
61 feature = "persistent-pool-rayon",
62 not(all(feature = "wasm", target_arch = "wasm32")),
63))]
64pub type DefaultPool = &'static rayon_core::ThreadPool;
66
67#[cfg(all(
69 feature = "std",
70 feature = "transient-pool",
71 not(all(feature = "wasm", target_arch = "wasm32")),
72 not(feature = "persistent-pool-rayon"),
73))]
74pub type DefaultPool = &'static OncePool;
76
77#[cfg(all(
79 feature = "std",
80 not(all(feature = "wasm", target_arch = "wasm32")),
81 not(feature = "persistent-pool-rayon"),
82 not(feature = "transient-pool"),
83))]
84pub type DefaultPool = &'static BasicPool;
86
87#[cfg(all(
89 not(feature = "std"),
90 not(all(feature = "wasm", target_arch = "wasm32")),
91 not(feature = "persistent-pool-rayon"),
92 not(feature = "transient-pool"),
93))]
94pub type DefaultPool = &'static SequentialPool;
96
97#[cfg(all(feature = "std", feature = "wasm", target_arch = "wasm32"))]
101pub(crate) fn global_pool() -> DefaultPool {
102 &PERSISTENT_POOL
103}
104
105#[cfg(all(
107 feature = "std",
108 feature = "persistent-pool-rayon",
109 not(all(feature = "wasm", target_arch = "wasm32")),
110))]
111pub(crate) fn global_pool() -> DefaultPool {
112 &PERSISTENT_POOL
113}
114
115#[cfg(all(
117 feature = "std",
118 feature = "transient-pool",
119 not(all(feature = "wasm", target_arch = "wasm32")),
120 not(feature = "persistent-pool-rayon"),
121))]
122pub(crate) fn global_pool() -> DefaultPool {
123 &PERSISTENT_POOL
124}
125
126#[cfg(all(
128 feature = "std",
129 not(all(feature = "wasm", target_arch = "wasm32")),
130 not(feature = "persistent-pool-rayon"),
131 not(feature = "transient-pool"),
132))]
133pub(crate) fn global_pool() -> DefaultPool {
134 &PERSISTENT_POOL
135}
136
137#[cfg(all(
139 not(feature = "std"),
140 not(all(feature = "wasm", target_arch = "wasm32")),
141 not(feature = "persistent-pool-rayon"),
142 not(feature = "transient-pool"),
143))]
144pub(crate) fn global_pool() -> DefaultPool {
145 &PERSISTENT_POOL
146}