#include <senf/Scheduler/WriteHelper.hh>
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 54 of file WriteHelper.hh.
Public Types |
|
typedef boost::intrusive_ptr < WriteHelper > |
ptr |
Smart pointer type for this class. |
|
typedef boost::function< void(ptr)> | Callback |
Callback type. |
|
Public Member Functions |
|
Handle | handle () const |
std::string const & | data () const |
Return the data. |
|
bool | complete () const |
Check whether the write has completed successfully. |
|
bool | error () const |
Check for error condition. |
|
void | throw_error () const |
If an error occurred, throw it. |
|
void | revoke () |
Remove the WriteHelper from the scheduler. |
|
Structors and default members |
|
static ptr | dispatch (Handle handle, std::string const &data, Callback callback) |
Register new WriteHelper instance. |
typedef boost::function<void (ptr)> senf::WriteHelper< Handle >:: | ||||
Callback | ||||
Callback type.
Definition at line 62 of file WriteHelper.hh.
typedef boost::intrusive_ptr<WriteHelper> senf::WriteHelper< Handle >:: | ||||
ptr | ||||
Smart pointer type for this class.
Definition at line 61 of file WriteHelper.hh.
bool senf::WriteHelper< Handle >:: | ||||
complete | () | |||
Check whether the write has completed successfully.
Definition at line 47 of file WriteHelper.cti.
std::string const & senf::WriteHelper< Handle >:: | ||||
data | () | |||
Return the data.
After all data has been sent, this member will return an empty string. Until then, the complete string will be returned.
Definition at line 43 of file WriteHelper.ct.
senf::WriteHelper< Handle >::ptr senf::WriteHelper< Handle >:: | ||||
dispatch | ( | Handle | handle, | |
std::string const & | data, | |||
Callback | callback | ) | ||
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 |
Definition at line 34 of file WriteHelper.cti.
bool senf::WriteHelper< Handle >:: | ||||
error | () | |||
Check for error condition.
Definition at line 54 of file WriteHelper.cti.
Handle senf::WriteHelper< Handle >:: | ||||
handle | () | |||
Definition at line 40 of file WriteHelper.cti.
void senf::WriteHelper< Handle >:: | ||||
revoke | () | |||
Remove the WriteHelper from the scheduler.
Definition at line 54 of file WriteHelper.ct.
void senf::WriteHelper< Handle >:: | ||||
throw_error | () | |||
If an error occurred, throw it.
Definition at line 61 of file WriteHelper.cti.