Ethereum  PoC-8
The C++ Implementation of Ethereum
dev::Worker Class Reference

#include <Worker.h>

Inheritance diagram for dev::Worker:
dev::eth::Client dev::eth::ClientTest

Protected Member Functions

 Worker (std::string const &_name="anon", unsigned _idleWaitMs=30)
 
 Worker (Worker &&_m)
 Move-constructor. More...
 
Workeroperator= (Worker &&_m)
 Move-assignment. More...
 
virtual ~Worker ()
 
void setName (std::string _n)
 Allows changing worker name if work is stopped. More...
 
void startWorking ()
 Starts worker thread; causes startedWorking() to be called. More...
 
void stopWorking ()
 Stop worker thread; causes call to stopWorking(). More...
 
bool isWorking () const
 Returns if worker thread is present. More...
 
virtual void startedWorking ()
 Called after thread is started from startWorking(). More...
 
virtual void doWork ()
 Called continuously following sleep for m_idleWaitMs. More...
 
virtual void workLoop ()
 Overrides doWork(); should call shouldStop() often and exit when true. More...
 
bool shouldStop () const
 
virtual void doneWorking ()
 Called when is to be stopped, just prior to thread being joined. More...
 
void terminate ()
 Blocks caller into worker thread has finished. More...
 

Detailed Description

Definition at line 48 of file Worker.h.

Constructor & Destructor Documentation

◆ Worker() [1/2]

dev::Worker::Worker ( std::string const &  _name = "anon",
unsigned  _idleWaitMs = 30 
)
inlineprotected

Definition at line 51 of file Worker.h.

◆ Worker() [2/2]

dev::Worker::Worker ( Worker &&  _m)
inlineprotected

Move-constructor.

Definition at line 54 of file Worker.h.

◆ ~Worker()

virtual dev::Worker::~Worker ( )
inlineprotectedvirtual

Definition at line 64 of file Worker.h.

Member Function Documentation

◆ doneWorking()

virtual void dev::Worker::doneWorking ( )
inlineprotectedvirtual

Called when is to be stopped, just prior to thread being joined.

Reimplemented in dev::eth::Client.

Definition at line 89 of file Worker.h.

◆ doWork()

virtual void dev::Worker::doWork ( )
inlineprotectedvirtual

Called continuously following sleep for m_idleWaitMs.

Reimplemented in dev::eth::Client.

Definition at line 82 of file Worker.h.

◆ isWorking()

bool dev::Worker::isWorking ( ) const
inlineprotected

Returns if worker thread is present.

Definition at line 76 of file Worker.h.

◆ operator=()

Worker& dev::Worker::operator= ( Worker &&  _m)
inlineprotected

Move-assignment.

Definition at line 57 of file Worker.h.

◆ setName()

void dev::Worker::setName ( std::string  _n)
inlineprotected

Allows changing worker name if work is stopped.

Definition at line 67 of file Worker.h.

◆ shouldStop()

bool dev::Worker::shouldStop ( ) const
inlineprotected

Definition at line 86 of file Worker.h.

◆ startedWorking()

virtual void dev::Worker::startedWorking ( )
inlineprotectedvirtual

Called after thread is started from startWorking().

Reimplemented in dev::eth::Client.

Definition at line 79 of file Worker.h.

◆ startWorking()

void Worker::startWorking ( )
protected

Starts worker thread; causes startedWorking() to be called.

Definition at line 30 of file Worker.cpp.

◆ stopWorking()

void Worker::stopWorking ( )
protected

Stop worker thread; causes call to stopWorking().

Definition at line 100 of file Worker.cpp.

◆ terminate()

void Worker::terminate ( )
protected

Blocks caller into worker thread has finished.

Stop and never start again. This has to be called in the destructor of any most derived class. Otherwise the worker thread will try to lookup vptrs. It's OK to call terminate() in destructors of multiple derived classes.

Definition at line 116 of file Worker.cpp.

◆ workLoop()

void Worker::workLoop ( )
protectedvirtual

Overrides doWork(); should call shouldStop() often and exit when true.

Definition at line 134 of file Worker.cpp.


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