libtasks Documentation  1.6
tasks::disk_io_task Class Reference

#include <disk_io_task.h>

Inheritance diagram for tasks::disk_io_task:
Collaboration diagram for tasks::disk_io_task:

Public Member Functions

 disk_io_task (int fd, int events, tools::buffer *buf)
 
virtual ~disk_io_task ()
 
std::string get_string () const
 
std::streamsize bytes () const
 
virtual bool handle_event (worker *worker, int events)
 
virtual void init_watcher ()
 Initialize the underlying watcher object. More...
 
virtual void start_watcher (worker *)
 Activate the underlying watcher to listen for I/O or timer events. More...
 
virtual void stop_watcher (worker *)
 Deactivate the underlying watcher. More...
 
virtual void dispose (worker *worker=nullptr)
 
- Public Member Functions inherited from tasks::event_task
virtual ~event_task ()
 
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...
 

Static Public Member Functions

static std::shared_future
< std::streamsize > 
add_task (disk_io_task *task)
 

Private Member Functions

std::shared_future
< std::streamsize > 
op ()
 

Private Attributes

int m_fd = -1
 
int m_events = EV_UNDEF
 
tools::bufferm_buf = nullptr
 
std::streamsize m_bytes = -1
 

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

Definition at line 21 of file disk_io_task.h.

Constructor & Destructor Documentation

tasks::disk_io_task::disk_io_task ( int  fd,
int  events,
tools::buffer buf 
)

Definition at line 15 of file disk_io_task.cpp.

Here is the call graph for this function:

tasks::disk_io_task::~disk_io_task ( )
virtual

Definition at line 19 of file disk_io_task.cpp.

Here is the call graph for this function:

Member Function Documentation

static std::shared_future<std::streamsize> tasks::disk_io_task::add_task ( disk_io_task task)
inlinestatic

Definition at line 41 of file disk_io_task.h.

Here is the call graph for this function:

Here is the caller graph for this function:

std::streamsize tasks::disk_io_task::bytes ( ) const
inline

Definition at line 32 of file disk_io_task.h.

Here is the caller graph for this function:

void tasks::disk_io_task::dispose ( worker worker = nullptr)
virtual

Definition at line 58 of file disk_io_task.cpp.

Here is the call graph for this function:

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

Definition at line 26 of file disk_io_task.h.

Here is the caller graph for this function:

bool tasks::disk_io_task::handle_event ( worker worker,
int  events 
)
virtual

Will be called for each I/O or timer event.

Each task needs to implement the handle_event method. Returns true if the task stays active and false otherwise. The task will be deleted if false is returned and auto_delete() returns true.

Parameters
workerThe worker thread executing the task.
eventsThe events bitmask.
Returns
True to continue execution. False to remove the task.

Implements tasks::event_task.

Definition at line 53 of file disk_io_task.cpp.

Here is the call graph for this function:

virtual void tasks::disk_io_task::init_watcher ( )
inlinevirtual

Initialize the underlying watcher object.

Implements tasks::event_task.

Definition at line 35 of file disk_io_task.h.

std::shared_future< std::streamsize > tasks::disk_io_task::op ( )
private

Definition at line 21 of file disk_io_task.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void tasks::disk_io_task::start_watcher ( worker worker)
inlinevirtual

Activate the underlying watcher to listen for I/O or timer events.

Implements tasks::event_task.

Definition at line 36 of file disk_io_task.h.

virtual void tasks::disk_io_task::stop_watcher ( worker worker)
inlinevirtual

Deactivate the underlying watcher.

Implements tasks::event_task.

Definition at line 37 of file disk_io_task.h.

Member Data Documentation

tools::buffer* tasks::disk_io_task::m_buf = nullptr
private

Definition at line 49 of file disk_io_task.h.

std::streamsize tasks::disk_io_task::m_bytes = -1
private

Definition at line 50 of file disk_io_task.h.

int tasks::disk_io_task::m_events = EV_UNDEF
private

Definition at line 48 of file disk_io_task.h.

int tasks::disk_io_task::m_fd = -1
private

Definition at line 47 of file disk_io_task.h.


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