Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Examples  

SUETimeoutHandler Class Reference

Timeout handler for SUEEventSelector. More...

#include <sue_sel.hpp>

Inheritance diagram for SUETimeoutHandler:

Inheritance graph
[legend]
List of all members.

Public Methods

 SUETimeoutHandler (long a_sec, long a_usec)
 Constructor of a full form.

 SUETimeoutHandler ()
 Default constructor.

virtual ~SUETimeoutHandler ()
 Destructor.

void Set (long a_sec, long a_usec)
 Set the timeout in absolute time.

void SetFromNow (long a_sec, long a_usec=0)
 Set the timeout relative to the current time.

void Get (long &a_sec, long &a_usec) const
 Read the value. Used primarily by SUEEventSelector.

void GetRemainingTime (long &a_sec, long &a_usec) const
 Read the value, call gettimeofday(3) and return the difference.

bool operator< (const SUETimeoutHandler &other) const
 Compare two timevalues. Used primarily by SUEEventSelector.

bool IsBefore (long a_sec, long a_usec) const
 Is it before the given moment.

virtual void TimeoutHandle ()=0
 Callback function for notification.


Friends

class SUEEventSelector

Detailed Description

Timeout handler for SUEEventSelector.

When we wish the SUEEventSelector to notify us that a given time event happens, we create a sublcass of SUETimeoutHandler and register it with the SUEEventSelector object.

Note:
The SUETimeoutHandler object remains registered unless the event happens and the notification is done OR it is unregistered explicitly.
Warning:
Changing the timeout value when the object is registered will lead to unpredictable behaviour.
Examples:

children.cpp, sitter.cpp, and sleep5.cpp.


Constructor & Destructor Documentation

SUETimeoutHandler::SUETimeoutHandler long    a_sec,
long    a_usec
 

Constructor of a full form.

This form of constructor allows to pass the actual moment to notify us at.

SUETimeoutHandler::SUETimeoutHandler  
 

Default constructor.

This form assumes we'll set the timeout value later with Set or SetFromNow methods

virtual SUETimeoutHandler::~SUETimeoutHandler   [virtual]
 

Destructor.

Warning:
it's the user's duty to make sure the object is no longer registered before destroying it


Member Function Documentation

void SUETimeoutHandler::Get long &    a_sec,
long &    a_usec
const
 

Read the value. Used primarily by SUEEventSelector.

void SUETimeoutHandler::GetRemainingTime long &    a_sec,
long &    a_usec
const
 

Read the value, call gettimeofday(3) and return the difference.

bool SUETimeoutHandler::IsBefore long    a_sec,
long    a_usec
const [inline]
 

Is it before the given moment.

bool SUETimeoutHandler::operator< const SUETimeoutHandler &    other const [inline]
 

Compare two timevalues. Used primarily by SUEEventSelector.

void SUETimeoutHandler::Set long    a_sec,
long    a_usec
 

Set the timeout in absolute time.

Set the actual moment when we need to be notified.

Parameters:
a_sec  seconds since epoch when the timeout is to happen
a_usec  microseconds (in addition to sec)

void SUETimeoutHandler::SetFromNow long    a_sec,
long    a_usec = 0
 

Set the timeout relative to the current time.

Set the time interval after which the timeout is to happen. The method actually calls gettimeofday(3) and adds the arguments to the values returned.

Parameters:
a_sec  - seconds
a_usec  - microseconds
Examples:
children.cpp, and sitter.cpp.

virtual void SUETimeoutHandler::TimeoutHandle   [pure virtual]
 

Callback function for notification.

The SUEEventSelector calls this method when the specified moment comes. After that, we can assume the object is no longer registered so it is possible to set a new value and register it again, even from within the TimeoutHandle() function itself (because SUEEventSelector unregisters the handler before calling the method).

Note:
This method MUST be overriden in a subclass in order to provide the appropriate functionality.

Implemented in SUEGenericDuplexSession.

Examples:
children.cpp, sitter.cpp, and sleep5.cpp.


Friends And Related Function Documentation

friend class SUEEventSelector [friend]
 


The documentation for this class was generated from the following file:
Generated on Fri Feb 27 13:17:28 2004 for SUE Library by doxygen1.2.18