pub struct ThreadPool {
pub threads: Vec<UnsafeCell<*mut Searcher>>,
pub main_cond: Arc<LockLatch>,
pub thread_cond: Arc<LockLatch>,
pub stop: AtomicBool,
/* private fields */
}Expand description
The thread-pool for the chess engine.
Fields§
§threads: Vec<UnsafeCell<*mut Searcher>>Access to each thread’s Structure
main_cond: Arc<LockLatch>Condition for the main thread to start.
thread_cond: Arc<LockLatch>Condition for all non-main threads
stop: AtomicBoolStop condition, if true the threads should halt.
Implementations§
Source§impl ThreadPool
impl ThreadPool
Sourcepub fn stdout(&mut self, use_stdout: bool)
pub fn stdout(&mut self, use_stdout: bool)
Sets the use of standard out. This can be changed mid search as well.
Sourcepub fn set_thread_count(&mut self, num: usize)
pub fn set_thread_count(&mut self, num: usize)
Sets the thread count of the pool. If num is less than 1, nothing will happen.
§Safety
Completely unsafe to use when the pool is searching.
Sourcepub fn kill_all(&mut self)
pub fn kill_all(&mut self)
Kills and de-allocates all the threads that are running. This function will also block on waiting for the search to finish.
Sourcepub fn wait_for_finish(&self)
pub fn wait_for_finish(&self)
Waits for all the threads to finish
Sourcepub fn wait_for_start(&self)
pub fn wait_for_start(&self)
Waits for all the threads to start.
Sourcepub fn wait_for_non_main(&self)
pub fn wait_for_non_main(&self)
Waits for all non-main threads to finish.
Sourcepub fn wait_for_main_start(&self)
pub fn wait_for_main_start(&self)
Waits for all the non-main threads to start running
pub fn clear_all(&mut self)
Sourcepub fn uci_search(&mut self, board: &Board, limits: &Limits)
pub fn uci_search(&mut self, board: &Board, limits: &Limits)
Starts a UCI search. The result will be printed to stdout if the stdout setting is true.