libtasks Documentation  1.6
tasks::io_task_base Class Referenceabstract

This is the base class for io event tasks. It controls an ev_io watcher that monitors io events on file handles. More...

#include <io_task_base.h>

Inheritance diagram for tasks::io_task_base:
Collaboration diagram for tasks::io_task_base:

Public Member Functions

 io_task_base (int events)
 
virtual ~io_task_base ()
 
std::string get_string () const
 
int events () const
 Return the monitored events. More...
 
ev_io * watcher () const
 Return the io watcher object. More...
 
virtual void init_watcher ()
 Initialize the watcher. More...
 
virtual void start_watcher (worker *worker)
 Start a watcher in the context of the given worker. More...
 
virtual void stop_watcher (worker *worker)
 Stop a watcher in the context of the given worker. More...
 
virtual void update_watcher (worker *worker)
 Udate a watcher in the context of the given worker. More...
 
virtual void dispose (worker *worker)
 Stop the watcher before being deleted. More...
 
- Public Member Functions inherited from tasks::event_task
virtual ~event_task ()
 
virtual bool handle_event (worker *worker, int events)=0
 
workerassigned_worker () const
 Returns a pointer to the assigned worker. More...
 
void assign_worker (worker *worker)
 
void notify_error (worker *worker=nullptr)
 
void on_error (error_func_worker_t f)
 
void on_error (error_func_void_t f)
 Install an error callback. More...
 
- Public Member Functions inherited from tasks::task
virtual ~task ()
 
bool auto_delete () const
 Returns true if auto deletion is active. More...
 
void disable_auto_delete ()
 Call this to deactivate auto deletion. More...
 
void finish (worker *worker=nullptr)
 Called by a worker when a task has auto_deletion enabled. More...
 
void on_finish (finish_func_worker_t f)
 
void on_finish (finish_func_void_t f)
 
- Public Member Functions inherited from tasks::error_base
 error_base ()
 
virtual ~error_base ()
 
bool error () const
 Return true if an error occured. More...
 
tasks_error error_code () const
 Return the error code. More...
 
const std::string & error_message () const
 Return the error message. More...
 
int sys_errno () const
 Return the errno if available. More...
 
std::string sys_errno_str () const
 Return the errno description if available. More...
 
const tasks_exceptionexception () const
 Return the underlying exception object. More...
 
void set_exception (tasks_exception &e)
 Set an exception to report an error. More...
 
void reset_error ()
 Reset the error state. More...
 
- Public Member Functions inherited from tasks::disposable
 disposable ()
 
virtual ~disposable ()
 
bool can_dispose () const
 Check if a task can be disposed or not. More...
 
void disable_dispose ()
 Mark a task for being not disposable. More...
 
void enable_dispose ()
 Mark a task for being disposable. More...
 

Protected Member Functions

virtual io_baseiob ()=0
 Return the io_base object. More...
 
virtual const io_baseiob () const =0
 Return a const io_base object. More...
 
void set_events (int events)
 Update the events the object monitors. More...
 

Private Attributes

std::unique_ptr< ev_io > m_io
 
bool m_watcher_initialized = false
 
int m_events = EV_UNDEF
 
bool m_change_pending = false
 

Additional Inherited Members

- Public Types inherited from tasks::event_task
typedef std::function< void(worker
*worker, const tasks_exception
&e)> 
error_func_worker_t
 
typedef std::function< void(const
tasks_exception &e)> 
error_func_void_t
 
- Public Types inherited from tasks::task
typedef std::function< void(worker
*worker)> 
finish_func_worker_t
 
typedef std::function< void()> finish_func_void_t
 

Detailed Description

This is the base class for io event tasks. It controls an ev_io watcher that monitors io events on file handles.

Definition at line 26 of file io_task_base.h.

Constructor & Destructor Documentation

tasks::io_task_base::io_task_base ( int  events)

Definition at line 14 of file io_task_base.cpp.

Here is the call graph for this function:

virtual tasks::io_task_base::~io_task_base ( )
inlinevirtual

Definition at line 29 of file io_task_base.h.

Member Function Documentation

void tasks::io_task_base::dispose ( worker worker)
virtual

Stop the watcher before being deleted.

Implements tasks::disposable.

Definition at line 73 of file io_task_base.cpp.

Here is the call graph for this function:

int tasks::io_task_base::events ( ) const
inline

Return the monitored events.

Definition at line 38 of file io_task_base.h.

Here is the caller graph for this function:

std::string tasks::io_task_base::get_string ( ) const
inline

Definition at line 31 of file io_task_base.h.

Here is the caller graph for this function:

void tasks::io_task_base::init_watcher ( )
virtual

Initialize the watcher.

Implements tasks::event_task.

Definition at line 21 of file io_task_base.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual io_base& tasks::io_task_base::iob ( )
protectedpure virtual

Return the io_base object.

Implemented in tasks::net_io_task, and tasks::serial_io_task.

Here is the caller graph for this function:

virtual const io_base& tasks::io_task_base::iob ( ) const
protectedpure virtual

Return a const io_base object.

Implemented in tasks::net_io_task, and tasks::serial_io_task.

void tasks::io_task_base::set_events ( int  events)
protected

Update the events the object monitors.

Definition at line 27 of file io_task_base.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void tasks::io_task_base::start_watcher ( worker worker)
virtual

Start a watcher in the context of the given worker.

Implements tasks::event_task.

Definition at line 35 of file io_task_base.cpp.

Here is the call graph for this function:

void tasks::io_task_base::stop_watcher ( worker worker)
virtual

Stop a watcher in the context of the given worker.

Implements tasks::event_task.

Definition at line 45 of file io_task_base.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void tasks::io_task_base::update_watcher ( worker worker)
virtual

Udate a watcher in the context of the given worker.

Definition at line 55 of file io_task_base.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

ev_io* tasks::io_task_base::watcher ( ) const
inline

Return the io watcher object.

Definition at line 40 of file io_task_base.h.

Here is the caller graph for this function:

Member Data Documentation

bool tasks::io_task_base::m_change_pending = false
private

Definition at line 68 of file io_task_base.h.

int tasks::io_task_base::m_events = EV_UNDEF
private

Definition at line 67 of file io_task_base.h.

std::unique_ptr<ev_io> tasks::io_task_base::m_io
private

Definition at line 65 of file io_task_base.h.

bool tasks::io_task_base::m_watcher_initialized = false
private

Definition at line 66 of file io_task_base.h.


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