libosmscout  0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules
osmscout::ThreadedWorker Class Referenceabstract

A single threaded agent. More...

#include <Worker.h>

+ Inheritance diagram for osmscout::ThreadedWorker:

Public Member Functions

 ThreadedWorker ()=default
 
 ThreadedWorker (const ThreadedWorker &other)=delete
 
 ThreadedWorker (ThreadedWorker &&other)=delete
 
void Wait ()
 
bool WasSuccessful () const
 Returns true if the worker processed successfully, else false. More...
 
virtual ~ThreadedWorker ()=default
 

Protected Member Functions

void MarkWorkerAsFailed ()
 Worker can set itself to the failure status. More...
 
virtual void ProcessingLoop ()=0
 
void Start ()
 

Detailed Description

A single threaded agent.

This is a simple wrapper around the std::thread primitive.

Note: ProcessingLoop method is pure virtual in ThreadedWorker. It may be called only after Vtable of child object is constructed. For that reason it is responsibility for child class to call Start method from its constructor. It is also beneficial to mark child classes as final.

Constructor & Destructor Documentation

◆ ThreadedWorker() [1/3]

osmscout::ThreadedWorker::ThreadedWorker ( )
default

◆ ThreadedWorker() [2/3]

osmscout::ThreadedWorker::ThreadedWorker ( const ThreadedWorker other)
delete

◆ ThreadedWorker() [3/3]

osmscout::ThreadedWorker::ThreadedWorker ( ThreadedWorker &&  other)
delete

◆ ~ThreadedWorker()

virtual osmscout::ThreadedWorker::~ThreadedWorker ( )
virtualdefault

Member Function Documentation

◆ MarkWorkerAsFailed()

void osmscout::ThreadedWorker::MarkWorkerAsFailed ( )
inlineprotected

Worker can set itself to the failure status.

This can later on queried by the parent process after Wait() to stop further processing.

The status is not protected by a mutex, please only call from inside the worker.

We currently do not support propagation of an detailed error object. We assume that the worker itself logs its error and that the parent worker is only interested in a boolean status.

This might change in future.

◆ ProcessingLoop()

virtual void osmscout::ThreadedWorker::ProcessingLoop ( )
protectedpure virtual

Referenced by Start().

◆ Start()

void osmscout::ThreadedWorker::Start ( )
inlineprotected

References ProcessingLoop().

◆ Wait()

void osmscout::ThreadedWorker::Wait ( )
inline

◆ WasSuccessful()

bool osmscout::ThreadedWorker::WasSuccessful ( ) const
inline

Returns true if the worker processed successfully, else false.

Please do not call before Wait() return. If called before Wait() the status may not be final. Also the value is not protected by a mutex.

Returns
true or false

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