OpenCPN Partial API docs
Loading...
Searching...
No Matches
ThreadCtrl Class Reference

Thread mixin providing a "stop thread"/"wait until stopped" interface. More...

#include <thread_ctrl.h>

Inheritance diagram for ThreadCtrl:
SerialIo AndroidSerialIo StdSerialIo

Public Member Functions

virtual ~ThreadCtrl ()=default
 Destroy the Thread Ctrl object.
 
bool IsRunning () const
 Return true if thread is running.
 
virtual void RequestStop ()
 Request that thread stops operation.
 
void WaitUntilStopped ()
 Block until thread invokes SignalExit().
 
bool WaitUntilStopped (std::chrono::duration< int > timeout)
 Block until thread invokes SignalExit() or timeout.
 
bool WaitUntilStopped (std::chrono::duration< int > timeout, std::chrono::milliseconds &elapsed)
 Block until thread invokes SignalExit() or timeout.
 

Protected Member Functions

bool KeepGoing () const
 If true continue thread operation, else exit and invoke SignalExit()
 
void SignalExit ()
 Signal that thread has exited.
 

Detailed Description

Thread mixin providing a "stop thread"/"wait until stopped" interface.

Definition at line 31 of file thread_ctrl.h.

Constructor & Destructor Documentation

◆ ThreadCtrl()

ThreadCtrl::ThreadCtrl ( )
inline

Definition at line 33 of file thread_ctrl.h.

Member Function Documentation

◆ IsRunning()

bool ThreadCtrl::IsRunning ( ) const
inline

Return true if thread is running.

Definition at line 41 of file thread_ctrl.h.

◆ KeepGoing()

bool ThreadCtrl::KeepGoing ( ) const
protected

If true continue thread operation, else exit and invoke SignalExit()

Definition at line 54 of file thread_ctrl.cpp.

◆ RequestStop()

void ThreadCtrl::RequestStop ( )
virtual

Request that thread stops operation.

Reimplemented in AndroidSerialIo, and SerialIo.

Definition at line 26 of file thread_ctrl.cpp.

◆ SignalExit()

void ThreadCtrl::SignalExit ( )
protected

Signal that thread has exited.

Definition at line 59 of file thread_ctrl.cpp.

◆ WaitUntilStopped() [1/3]

void ThreadCtrl::WaitUntilStopped ( )

Block until thread invokes SignalExit().

Definition at line 31 of file thread_ctrl.cpp.

◆ WaitUntilStopped() [2/3]

bool ThreadCtrl::WaitUntilStopped ( std::chrono::duration< int >  timeout)

Block until thread invokes SignalExit() or timeout.

Returns
false if the timeout triggered, else true.

Definition at line 36 of file thread_ctrl.cpp.

◆ WaitUntilStopped() [3/3]

bool ThreadCtrl::WaitUntilStopped ( std::chrono::duration< int >  timeout,
std::chrono::milliseconds &  elapsed 
)

Block until thread invokes SignalExit() or timeout.

Parameters
timeoutMaximum time to wait for thread to exit.
elapsedOn exit, the time spent in method.
Returns
false if the timeout triggered, else true.

Definition at line 42 of file thread_ctrl.cpp.


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