fw4spl
fwThread::WorkerAsio Class Reference

Private implementation of fwThread::Worker using boost::asio. More...

+ Inheritance diagram for fwThread::WorkerAsio:
+ Collaboration diagram for fwThread::WorkerAsio:

Public Types

typedef ::boost::asio::io_service IOServiceType
 
typedef ::boost::asio::io_service::work WorkType
 
typedef std::shared_ptr< WorkType > WorkPtrType
 
typedef std::thread ThreadType
 
- Public Types inherited from fwThread::Worker
typedef ::fwCore::HiResClock::HiResClockType PeriodType
 
typedef std::function< void() > TaskType
 
typedef ::boost::any ExitReturnType
 
typedef std::shared_future< ExitReturnType > FutureType
 

Public Member Functions

void stop ()
 Waits for the last task to be processed and stops the loop.
 
void post (TaskType handler)
 Requests invocation of the given task handler and returns immediately.
 
ThreadIdType getThreadId () const
 Returns the worker's thread id.
 
std::shared_ptr< ::fwThread::TimercreateTimer ()
 Creates and returns a fwThread::Timer running in this Worker.
 
virtual void processTasks ()
 Processes all worker pending tasks for the calling thread until there are no more tasks to process. You can call this function occasionally when your program is busy performing a long operation. More...
 
virtual void processTasks (PeriodType maxtime)
 Processes worker pending tasks for the calling thread for maxtime milliseconds or until there are no more tasks to process. You can call this function occasionally when your program is busy performing a long operation. More...
 
- Public Member Functions inherited from fwThread::Worker
virtual bool isA (const std::string &type) const override
 
template<typename R , typename CALLABLE >
std::shared_future< R > postTask (CALLABLE f)
 Requests invocation of the given callable and returns a shared future. More...
 
virtual FutureType getFuture ()
 Returns a std::shared_future associated with the execution of Worker's loop. More...
 
template<typename R , typename TASK >
std::shared_future< R > postTask (TASK f)
 
virtual const std::string & getLeafClassname () const override
 return object's classname without its namespace, i.e. BaseObject
 
virtual const std::string & getClassname () const override
 return full object's classname with its namespace, i.e. fwCore::BaseObject
 
- Public Member Functions inherited from fwCore::BaseObject

Protected Member Functions

 WorkerAsio (const WorkerAsio &)
 Copy constructor forbidden.
 
WorkerAsiooperator= (const WorkerAsio &)
 Copy operator forbidden.
 
- Protected Member Functions inherited from fwThread::Worker
 Worker (const Worker &)
 Copy constructor forbidden.
 
Workeroperator= (const Worker &)
 Copy operator forbidden.
 

Protected Attributes

IOServiceType m_ioService
 Class provides functionality to manipulate asynchronous tasks.
 
WorkPtrType m_work
 Class to inform the io_service when it has work to do.
 
std::shared_ptr< ThreadType > m_thread
 Thread created and managed by the worker.
 
- Protected Attributes inherited from fwThread::Worker
FutureType m_future
 Worker's loop future.
 

Additional Inherited Members

- Static Public Member Functions inherited from fwThread::Worker
static bool isTypeOf (const std::string &type)
 
static const std::string & leafClassname ()
 return object's classname without its namespace, i.e. BaseObject
 
static const std::string & classname ()
 return object's classname without its namespace, i.e. BaseObject
 
- Static Public Member Functions inherited from fwCore::BaseObject
static bool isTypeOf (const std::string &type)
 
static const std::string & leafClassname ()
 return object's classname without its namespace, i.e. BaseObject
 
static const std::string & classname ()
 return object's classname without its namespace, i.e. BaseObject
 
- Static Protected Member Functions inherited from fwThread::Worker
static FWTHREAD_API std::shared_ptr< WorkerdefaultFactory ()
 

Detailed Description

Private implementation of fwThread::Worker using boost::asio.

Definition at line 31 of file WorkerAsio.cpp.

Member Function Documentation

void fwThread::WorkerAsio::processTasks ( )
virtual

Processes all worker pending tasks for the calling thread until there are no more tasks to process. You can call this function occasionally when your program is busy performing a long operation.

Warning
WxWidgets version is not yet implemented.

Implements fwThread::Worker.

Definition at line 197 of file WorkerAsio.cpp.

void fwThread::WorkerAsio::processTasks ( PeriodType  maxtime)
virtual

Processes worker pending tasks for the calling thread for maxtime milliseconds or until there are no more tasks to process. You can call this function occasionally when your program is busy performing a long operation.

Parameters
maxtimemilliseconds to process worker pending tasks.
Warning
Qt implementation processes all Qt and Worker pending events, be careful.
WxWidgets version is not yet implemented.

Implements fwThread::Worker.

Definition at line 204 of file WorkerAsio.cpp.

References fwCore::TimeStamp::modified(), fwCore::TimeStamp::periodExpired(), and fwCore::TimeStamp::setLifePeriod().

+ Here is the call graph for this function:


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