Fabcoin Core  0.16.2
P2P Digital Currency
Protected Member Functions | Private Member Functions | Private Attributes | List of all members
dev::Worker Class Reference

#include <Worker.h>

Inheritance diagram for dev::Worker:
[legend]

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...
 

Private Member Functions

void terminate ()
 Blocks caller into worker thread has finished. More...
 

Private Attributes

std::string m_name
 
unsigned m_idleWaitMs = 0
 
Mutex x_work
 Lock for the network existance. More...
 
std::unique_ptr< std::thread > m_work
 The network thread. More...
 
std::atomic< WorkerStatem_state = {WorkerState::Starting}
 

Detailed Description

Definition at line 48 of file Worker.h.

Constructor & Destructor Documentation

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

Definition at line 51 of file Worker.h.

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

Move-constructor.

Definition at line 54 of file Worker.h.

Here is the call graph for this function:

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

Definition at line 64 of file Worker.h.

Member Function Documentation

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

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

Reimplemented in dev::p2p::Host, dev::eth::Client, and TestHost.

Definition at line 89 of file Worker.h.

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

Called continuously following sleep for m_idleWaitMs.

Reimplemented in dev::p2p::Host, dev::eth::Client, dev::eth::EthereumHost, dev::shh::WhisperHost, and TestHost.

Definition at line 82 of file Worker.h.

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

Returns if worker thread is present.

Definition at line 76 of file Worker.h.

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

Move-assignment.

Definition at line 57 of file Worker.h.

Here is the call graph for this function:

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

Allows changing worker name if work is stopped.

Definition at line 67 of file Worker.h.

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

Definition at line 86 of file Worker.h.

Here is the caller graph for this function:

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

Called after thread is started from startWorking().

Reimplemented in dev::p2p::Host, and dev::eth::Client.

Definition at line 79 of file Worker.h.

void Worker::startWorking ( )
protected

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

Definition at line 30 of file Worker.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Worker::stopWorking ( )
protected

Stop worker thread; causes call to stopWorking().

Definition at line 85 of file Worker.cpp.

Here is the caller graph for this function:

void Worker::terminate ( )
private

Blocks caller into worker thread has finished.

Stop and never start again.

Definition at line 99 of file Worker.cpp.

void Worker::workLoop ( )
protectedvirtual

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

Reimplemented in dev::eth::EthashCPUMiner.

Definition at line 114 of file Worker.cpp.

Member Data Documentation

unsigned dev::Worker::m_idleWaitMs = 0
private

Definition at line 100 of file Worker.h.

std::string dev::Worker::m_name
private

Definition at line 98 of file Worker.h.

std::atomic<WorkerState> dev::Worker::m_state = {WorkerState::Starting}
private

Definition at line 104 of file Worker.h.

std::unique_ptr<std::thread> dev::Worker::m_work
private

The network thread.

Definition at line 103 of file Worker.h.

Mutex dev::Worker::x_work
mutableprivate

Lock for the network existance.

Definition at line 102 of file Worker.h.


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