Asynchronous writing helper. More...
#include <senf/Scheduler/WriteHelper.hh>
Public Types | |
typedef boost::intrusive_ptr< WriteHelper > | ptr |
Smart pointer type for this class. More... | |
typedef boost::function< void(ptr)> | Callback |
Callback type. More... | |
Public Types inherited from senf::intrusive_refcount_base | |
typedef unsigned | refcount_t |
Public Member Functions | |
Handle | handle () const |
std::string const & | data () const |
Return the data. More... | |
bool | complete () const |
Check whether the write has completed successfully. More... | |
bool | error () const |
Check for error condition. More... | |
void | throw_error () const |
If an error occurred, throw it. More... | |
void | revoke () |
Remove the WriteHelper from the scheduler. More... | |
Public Member Functions inherited from senf::intrusive_refcount_base | |
virtual | ~intrusive_refcount_base () |
refcount_t | refcount () const |
bool | is_shared () const |
Structors and default members | |
static ptr | dispatch (Handle handle, std::string const &data, Callback callback) |
Register new WriteHelper instance. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from senf::intrusive_refcount | |
intrusive_refcount () | |
Protected Member Functions inherited from intrusive_refcount_t< intrusive_refcount > | |
intrusive_refcount_t () | |
Protected Member Functions inherited from senf::intrusive_refcount_base | |
intrusive_refcount_base () | |
void | add_ref () |
bool | release () |
Asynchronous writing helper.
This class provides a simple asynchronous writing facility. This helper will register with the Scheduler to write the requested data. It will stay registered until the data has been completely sent or some error condition is encountered. As soon as the WriteHelper is done, the callback will be called.
The WriteHelper accepts the same flexible file handle interfaces as the Scheduler.
The callback must take a WriteHelper::ptr argument. Using this WriteHelper instance, the callback can access the state information and check the termination status.
Definition at line 47 of file WriteHelper.hh.
typedef boost::function<void (ptr)> senf::WriteHelper< Handle >::Callback |
Callback type.
Definition at line 55 of file WriteHelper.hh.
typedef boost::intrusive_ptr<WriteHelper> senf::WriteHelper< Handle >::ptr |
Smart pointer type for this class.
Definition at line 54 of file WriteHelper.hh.
bool senf::WriteHelper< Handle >::complete | ( | ) | const |
Check whether the write has completed successfully.
std::string const& senf::WriteHelper< Handle >::data | ( | ) | const |
Return the data.
After all data has been sent, this member will return an empty string. Until then, the complete string will be returned.
|
static |
Register new WriteHelper instance.
The registered callback will be called after all data has been sent or when some error condition is encountered.
[in] | handle | file descriptor or handle providing the Handle interface defined above. |
[in] | data | data to send |
[in] | callback | callback |
bool senf::WriteHelper< Handle >::error | ( | ) | const |
Check for error condition.
Handle senf::WriteHelper< Handle >::handle | ( | ) | const |
void senf::WriteHelper< Handle >::revoke | ( | ) |
Remove the WriteHelper from the scheduler.
void senf::WriteHelper< Handle >::throw_error | ( | ) | const |
If an error occurred, throw it.