![]() |
Scarab
v3.9.4
Project 8 C++ Utility Library
|
Lightweight wrapper for a cancelable object only temporarily added to signal_handler. More...
#include <cancelable.hh>
Public Member Functions | |
cancelable_wrapper (cancelable &a_cancelable) | |
virtual | ~cancelable_wrapper () |
virtual void | do_cancellation (int a_code) |
![]() | |
cancelable () | |
cancelable (const cancelable &a_orig) | |
cancelable (cancelable &&a_orig) | |
virtual | ~cancelable () |
cancelable & | operator= (const cancelable &a_orig) |
cancelable & | operator= (cancelable &&a_orig) |
void | cancel (int a_code=0) |
asynchronous cancel function More... | |
void | reset_cancel () |
reset to non-canceled state More... | |
bool | is_canceled () const |
check canceled state More... | |
Public Attributes | |
cancelable * | f_wrapped |
Additional Inherited Members | |
![]() | |
std::atomic< bool > | f_canceled |
Lightweight wrapper for a cancelable object only temporarily added to signal_handler.
Sometimes a cancelable object is created on the stack in a local scope, or it's temporarily added to signal_handler while a specific action is performed. In this case you can use this lightweight wrapper to add the cancelable object to the signal handler. NOTE: the wrapper does not track the lifetime of the wrapped object. Only use this wrapper if you can guarantee that the lifetime of the wrapped object is not shorter than that of the wrapper. Example: { my_cancelable t_obj; // here's the local object we want to have temporarily added to signal_handler auto t_obj_wrap = wrap_cancelable( t_obj ); // use wrap_cancelable() (declared below) to create the wrapper scarab::signal_handler t_handler; // creating the signal_handler sets the signal-handling functions, if it hasn't been done before t_handler.add_cancelable( t_obj_wrap ); // add the wrapper t_obj.execute(); // do the cancelable action
end of scope: t_obj_wrap is destroyed, which removes it from signal_handler automatically }
Definition at line 103 of file cancelable.hh.
cancelable_wrapper | ( | cancelable & | a_cancelable | ) |
Definition at line 69 of file cancelable.cc.
|
virtual |
Definition at line 73 of file cancelable.cc.
|
inlinevirtual |
Reimplemented from cancelable.
Definition at line 135 of file cancelable.hh.
cancelable* f_wrapped |
Definition at line 108 of file cancelable.hh.