Instrument Neutral Distributed Interface INDI  2.0.2
Public Member Functions | Protected Attributes | List of all members
INDI::SingleThreadPool Class Reference

#include <indisinglethreadpool.h>

Public Member Functions

 SingleThreadPool ()
 
 ~SingleThreadPool ()
 
void start (const std::function< void(const std::atomic_bool &isAboutToClose)> &functionToRun)
 Reserves a thread and uses it to run functionToRun. A running function can check the 'isAboutToClose' flag and decide whether to end the work and give the thread. More...
 
bool tryStart (const std::function< void(const std::atomic_bool &isAboutToClose)> &functionToRun)
 If thread isn't available at the time of calling, then this function does nothing and returns false. Otherwise, functionToRun is run immediately using thread and this function returns true. More...
 
void quit ()
 Sets the 'isAboutToClose' flag to 'true' and waits for the end of running function. More...
 

Protected Attributes

std::shared_ptr< SingleThreadPoolPrivated_ptr
 

Detailed Description

Definition at line 29 of file indisinglethreadpool.h.

Constructor & Destructor Documentation

◆ SingleThreadPool()

INDI::SingleThreadPool::SingleThreadPool ( )

Definition at line 64 of file indisinglethreadpool.cpp.

◆ ~SingleThreadPool()

INDI::SingleThreadPool::~SingleThreadPool ( )

Definition at line 68 of file indisinglethreadpool.cpp.

Member Function Documentation

◆ quit()

void INDI::SingleThreadPool::quit ( )

Sets the 'isAboutToClose' flag to 'true' and waits for the end of running function.

Definition at line 102 of file indisinglethreadpool.cpp.

◆ start()

void INDI::SingleThreadPool::start ( const std::function< void(const std::atomic_bool &isAboutToClose)> &  functionToRun)

Reserves a thread and uses it to run functionToRun. A running function can check the 'isAboutToClose' flag and decide whether to end the work and give the thread.

Definition at line 71 of file indisinglethreadpool.cpp.

◆ tryStart()

bool INDI::SingleThreadPool::tryStart ( const std::function< void(const std::atomic_bool &isAboutToClose)> &  functionToRun)

If thread isn't available at the time of calling, then this function does nothing and returns false. Otherwise, functionToRun is run immediately using thread and this function returns true.

Definition at line 84 of file indisinglethreadpool.cpp.

Member Data Documentation

◆ d_ptr

std::shared_ptr<SingleThreadPoolPrivate> INDI::SingleThreadPool::d_ptr
protected

Definition at line 50 of file indisinglethreadpool.h.


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