BenBot 1.7.5
A chess engine
Loading...
Searching...
No Matches
util::LargeStackThread Class Referencefinal

#include <libutil/Threading.hpp>

Public Member Functions

 LargeStackThread (const LargeStackThread &)=delete
 LargeStackThread (LargeStackThread &&)=delete
 LargeStackThread (std::size_t stackSize, std::function< void()> func)
 ~LargeStackThread ()
void join ()
LargeStackThread & operator= (const LargeStackThread &)=delete
LargeStackThread & operator= (LargeStackThread &&)=delete

Detailed Description

A thread with a stack of a chosen size.

std::thread always uses the platform's default stack size for new threads, which is only 512 KiB on macOS (and 1 MiB on Windows), so code that recurses deeply, like a chess search, should use this class instead.

The thread starts running the function as soon as it's constructed. It must be joined before it's destroyed.

Definition at line 39 of file Threading.hpp.

Constructor & Destructor Documentation

◆ LargeStackThread() [1/3]

util::LargeStackThread::LargeStackThread ( std::size_t stackSize,
std::function< void()> func )

Starts a new thread with a stack of at least stackSize bytes, which runs func. stackSize must be a multiple of 64 KiB.

Exceptions
std::system_errorif the thread can't be created

◆ ~LargeStackThread()

util::LargeStackThread::~LargeStackThread ( )

◆ LargeStackThread() [2/3]

util::LargeStackThread::LargeStackThread ( const LargeStackThread & )
delete

◆ LargeStackThread() [3/3]

util::LargeStackThread::LargeStackThread ( LargeStackThread && )
delete

Member Function Documentation

◆ join()

void util::LargeStackThread::join ( )

Blocks until the thread's function returns. This must be called exactly once.

◆ operator=() [1/2]

LargeStackThread & util::LargeStackThread::operator= ( const LargeStackThread & )
delete

◆ operator=() [2/2]

LargeStackThread & util::LargeStackThread::operator= ( LargeStackThread && )
delete

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