libtasks Documentation  1.6
tasks::disposable Class Referenceabstract

Base class for objects/tasks that can be deleted. More...

#include <disposable.h>

Inheritance diagram for tasks::disposable:

Public Member Functions

 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...
 
virtual void dispose (worker *)=0
 Dispose an object. More...
 

Private Attributes

std::atomic< bool > m_can_dispose
 

Detailed Description

Base class for objects/tasks that can be deleted.

We implement a simplistic garbage collector using timer tasks. If a task with auto_delete enabled can't be deleted directly by a worker thread, a dispose_task gets created that periodically tries to delete the task.

Definition at line 23 of file disposable.h.

Constructor & Destructor Documentation

tasks::disposable::disposable ( )
inline

Definition at line 25 of file disposable.h.

virtual tasks::disposable::~disposable ( )
inlinevirtual

Definition at line 26 of file disposable.h.

Member Function Documentation

bool tasks::disposable::can_dispose ( ) const
inline

Check if a task can be disposed or not.

Returns
True if the task can be disposed. False otherwise.

Definition at line 33 of file disposable.h.

Here is the caller graph for this function:

void tasks::disposable::disable_dispose ( )
inline

Mark a task for being not disposable.

Definition at line 38 of file disposable.h.

virtual void tasks::disposable::dispose ( worker )
pure virtual

Dispose an object.

Dispose is called to delete a task. Instead of calling delete directly we enable for hooking in here. This is required by the net_io_task for example to stop the watcher.

Implemented in tasks::io_task_base.

Here is the caller graph for this function:

void tasks::disposable::enable_dispose ( )
inline

Mark a task for being disposable.

Definition at line 43 of file disposable.h.

Member Data Documentation

std::atomic<bool> tasks::disposable::m_can_dispose
private

Definition at line 54 of file disposable.h.


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