UCILoader 1.1.2
Small C++ library that allows user to connect to a chess engines via UCI protocol.
Loading...
Searching...
No Matches
UCILoader::SearchStatusWrapper Class Reference

Thread-safe wrapper for managing SearchStatusCode state. More...

#include <EngineConnection.h>

Public Member Functions

void set (SearchStatusCode code)
 Set the search status to the specified code.
 
SearchStatusCode swapIfOngoing (SearchStatusCode newStatus)
 Atomically swap status if current status is OnGoing.
 
SearchStatusCode get ()
 Get the current search status.
 
SearchStatusCode waitFor (const std::chrono::milliseconds &dur)
 Block until the search status changes or timeout expires.
 
const SearchStatusCode & operator= (const SearchStatusCode &value)
 Assignment operator for convenient status setting.
 
bool operator== (const SearchStatusCode &value)
 
bool operator!= (const SearchStatusCode &value)
 

Detailed Description

Thread-safe wrapper for managing SearchStatusCode state.

Provides synchronized access to the search status with atomic-like operations. Supports blocking waits, condition variables, and compare-swap semantics for safe concurrent access. Used internally by SearchConnection to manage search state across multiple threads.

Member Function Documentation

◆ get()

SearchStatusCode UCILoader::SearchStatusWrapper::get ( )
inline

Get the current search status.

Returns
The current SearchStatusCode

◆ operator=()

const SearchStatusCode & UCILoader::SearchStatusWrapper::operator= ( const SearchStatusCode &  value)
inline

Assignment operator for convenient status setting.

Parameters
valueThe new status value
Returns
Reference to the assigned value

◆ set()

void UCILoader::SearchStatusWrapper::set ( SearchStatusCode  code)
inline

Set the search status to the specified code.

Parameters
codeThe new SearchStatusCode value

◆ swapIfOngoing()

SearchStatusCode UCILoader::SearchStatusWrapper::swapIfOngoing ( SearchStatusCode  newStatus)
inline

Atomically swap status if current status is OnGoing.

This is a compare-and-swap operation that only changes the status if it's currently OnGoing. Useful for implementing asynchronous timeouts and preventing race conditions.

Parameters
newStatusThe status to set if current status is OnGoing
Returns
The status value before this operation

◆ waitFor()

SearchStatusCode UCILoader::SearchStatusWrapper::waitFor ( const std::chrono::milliseconds &  dur)
inline

Block until the search status changes or timeout expires.

If the status remains OnGoing after the timeout period, automatically sets status to TimedOut.

Parameters
durMaximum duration to wait in milliseconds
Returns
The final SearchStatusCode (may be TimedOut if no change occurred)

The documentation for this class was generated from the following file: