Scale Stack 0.3 Developer Documentation

scalestack::event::handler Class Reference

#include <handler.h>

Inheritance diagram for scalestack::event::handler:
scalestack::event::test::handler scalestack::network::datagram_provider scalestack::network::listener scalestack::network::stream_provider scalestack::network::local::datagram::socket scalestack::network::local::stream::listener scalestack::network::ip::tcp::connection scalestack::network::local::stream::connection

Public Member Functions

 handler (handler_service &handler_service)
virtual ~handler ()
void start (void)
virtual void started (void)
virtual void shutdown (void)
void stop (void)
void set_timer (uint64_t milliseconds)
virtual void timer_expired (void)
void set_file_descriptor (int file_descriptor)
virtual void close_file_descriptor (int file_descriptor)
void watch_read (void)
virtual void read_ready (int file_descriptor)
void watch_write (void)
virtual void write_ready (int file_descriptor)
void run_now (void)
virtual void run (void)

Protected Attributes

kernel::module_module

Private Member Functions

 handler (const handler &)
handleroperator= (const handler &)
void _start (void)
void _stop (void)

Private Attributes

handler_service_handler_service
std::auto_ptr< handler_provider_handler_provider

Friends

class handler_provider
class handler_service

Detailed Description

This is the event handler base class. Other classes that want to handle events must derive from this.

Definition at line 49 of file handler.h.


Constructor & Destructor Documentation

scalestack::event::handler::handler ( handler_service handler_service  )  [inline]

Definition at line 258 of file handler.h.

scalestack::event::handler::~handler (  )  [inline, virtual]

Reimplemented in scalestack::event::test::handler.

Definition at line 265 of file handler.h.

scalestack::event::handler::handler ( const handler  )  [private]

Don't allow copying of objects.


Member Function Documentation

void scalestack::event::handler::start ( void   )  [inline]

Notify that this event handler is ready to be added to the event service. It is not automatically started on creation because derived classes may not be fully constructed. The started() method may be called before this returns since event service providers may manage this in another thread.

Definition at line 269 of file handler.h.

void scalestack::event::handler::started ( void   )  [inline, virtual]

This method is called after the event service has added the handler and is ready to be started.

Reimplemented in scalestack::event::test::handler, scalestack::network::datagram_provider, and scalestack::network::stream_provider.

Definition at line 274 of file handler.h.

void scalestack::event::handler::shutdown ( void   )  [inline, virtual]

This method is called to notify application that the handler should be shutdown. This can be triggered by applications or by the event service when a handler service is being shut down. The default behavior is to call stop(). If applications override this method, they need to eventually call stop() once other cleanup is taken care of.

Reimplemented in scalestack::network::datagram_provider, and scalestack::network::stream_provider.

Definition at line 278 of file handler.h.

void scalestack::event::handler::stop ( void   )  [inline]

Notify that this event handler should be stopped. Once this is called, no other methods should be called on the handler object.

Definition at line 283 of file handler.h.

void scalestack::event::handler::set_timer ( uint64_t  milliseconds  )  [inline]

Set the timer. Once this timer expires the timer_expired() method is called. Note the timer is not persistent, once the timer_expired() method is called, the timer is no longer set.

Parameters:
[in] milliseconds The number of milliseconds from now for the timer to expire. A value of 0 cancels the timer.

Definition at line 288 of file handler.h.

void scalestack::event::handler::timer_expired ( void   )  [inline, virtual]

This is called when the timer expires.

Reimplemented in scalestack::event::test::handler, scalestack::network::datagram_provider, and scalestack::network::stream_provider.

Definition at line 293 of file handler.h.

void scalestack::event::handler::set_file_descriptor ( int  file_descriptor  )  [inline]

Set the file descriptor to watch.

Parameters:
[in] file_descriptor The file descriptor to use when watching for read and write events.

Reimplemented in scalestack::network::datagram_provider, scalestack::network::ip::tcp::connection, and scalestack::network::stream_provider.

Definition at line 297 of file handler.h.

void scalestack::event::handler::close_file_descriptor ( int  file_descriptor  )  [inline, virtual]

This is called when a previously set file descriptor is no longer in use. The default behavior is to call close(2).

Reimplemented in scalestack::event::test::handler.

Definition at line 302 of file handler.h.

void scalestack::event::handler::watch_read ( void   )  [inline]

Notify the event service to watch for read events.

Definition at line 307 of file handler.h.

void scalestack::event::handler::read_ready ( int  file_descriptor  )  [inline, virtual]

This is called when the file descriptor is ready for reading.

Reimplemented in scalestack::event::test::handler, scalestack::network::datagram_provider, scalestack::network::listener, and scalestack::network::stream_provider.

Definition at line 312 of file handler.h.

void scalestack::event::handler::watch_write ( void   )  [inline]

Notify the event service to watch for write events.

Definition at line 316 of file handler.h.

void scalestack::event::handler::write_ready ( int  file_descriptor  )  [inline, virtual]

This is called when the file descriptor is ready for writing.

Reimplemented in scalestack::event::test::handler, scalestack::network::datagram_provider, and scalestack::network::stream_provider.

Definition at line 321 of file handler.h.

void scalestack::event::handler::run_now ( void   )  [inline]

Notify the event service to call run() for this handler from the event loop. This is needed when using event providers that are threaded, and you want the handler to be run on the thread it is assigned to.

Definition at line 325 of file handler.h.

void scalestack::event::handler::run ( void   )  [inline, virtual]

This is called when the event service receives a run_now() request.

Reimplemented in scalestack::event::test::handler, scalestack::network::datagram_provider, and scalestack::network::stream_provider.

Definition at line 330 of file handler.h.

handler& scalestack::event::handler::operator= ( const handler  )  [private]

Don't allow assignment of objects.

void scalestack::event::handler::_start ( void   )  [inline, private]

The start() method calls handler_service::_start_handler(), which in turn calls this method. This is required to make sure the event service is properly synchronized while adding new handlers.

Definition at line 338 of file handler.h.

void scalestack::event::handler::_stop ( void   )  [inline, private]

Stop the handler by removing it from the handler service and deleting the object.

Definition at line 343 of file handler.h.


Friends And Related Function Documentation

friend class handler_provider [friend]

Definition at line 180 of file handler.h.

friend class handler_service [friend]

Definition at line 181 of file handler.h.


Field Documentation

Definition at line 150 of file handler.h.

Definition at line 177 of file handler.h.

Definition at line 178 of file handler.h.


The documentation for this class was generated from the following file:
Generated on Thu Feb 17 13:10:22 2011 by  doxygen 1.6.3