senf::WriteHelper< Handle > Class Template Reference

Asynchronous writing helper. More...

#include <senf/Scheduler/WriteHelper.hh>

Inheritance diagram for senf::WriteHelper< Handle >:

Public Types

typedef boost::intrusive_ptr< WriteHelperptr
 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 ()
 

Detailed Description

template<class Handle>
class senf::WriteHelper< Handle >

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.

Todo:
Add additional interface to better access the intermediate status (data sent so far)

Definition at line 47 of file WriteHelper.hh.

Member Typedef Documentation

◆ Callback

template<class Handle >
typedef boost::function<void (ptr)> senf::WriteHelper< Handle >::Callback

Callback type.

Definition at line 55 of file WriteHelper.hh.

◆ ptr

template<class Handle >
typedef boost::intrusive_ptr<WriteHelper> senf::WriteHelper< Handle >::ptr

Smart pointer type for this class.

Definition at line 54 of file WriteHelper.hh.

Member Function Documentation

◆ complete()

template<class Handle >
bool senf::WriteHelper< Handle >::complete ( ) const

Check whether the write has completed successfully.

◆ data()

template<class Handle >
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.

◆ dispatch()

template<class Handle >
static ptr senf::WriteHelper< Handle >::dispatch ( Handle  handle,
std::string const &  data,
Callback  callback 
)
static

Register new WriteHelper instance.

The registered callback will be called after all data has been sent or when some error condition is encountered.

Parameters
[in]handlefile descriptor or handle providing the Handle interface defined above.
[in]datadata to send
[in]callbackcallback
Returns
smart pointer to new WriteHelper instance

◆ error()

template<class Handle >
bool senf::WriteHelper< Handle >::error ( ) const

Check for error condition.

◆ handle()

template<class Handle >
Handle senf::WriteHelper< Handle >::handle ( ) const

◆ revoke()

template<class Handle >
void senf::WriteHelper< Handle >::revoke ( )

Remove the WriteHelper from the scheduler.

◆ throw_error()

template<class Handle >
void senf::WriteHelper< Handle >::throw_error ( ) const

If an error occurred, throw it.


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