tamer Namespace Reference

Namespace containing public Tamer classes and functions for the Tamer core. More...


Classes

class  event
 A future occurrence. More...
class  fd
 A file descriptor wrapper with event-based access functions. More...
class  mutex
 An event-based mutual-exclusion lock. More...
class  rendezvous
 A set of watched events. More...

Namespaces

namespace  fdx
 Namespace containing extensions to Tamer's file descriptor support, such as helper functions for creating TCP connections.
namespace  tamerutil
 Namespace containing utility classes useful for Tamer implementation, and possibly elsewhere.

Functions

event distribute (const event<> &e1, const event<> &e2)
 Create event that triggers e1 and e2 when triggered.
event distribute (const event<> &e1, const event<> &e2, const event<> &e3)
 Create event that triggers e1, e2, and e3 when triggered.
template<typename T0, typename V0>
event bind (event< T0 > e, const V0 &v0)
 Create event that triggers e with v0 when triggered.
template<typename T0>
event< T0 > unbind (const event<> &e)
 Create 1-slot event that triggers e when triggered.
template<typename T0>
event< T0 > add_timeout (const timeval &delay, event< T0 > e)
 Add timeout to an event.
template<typename T0>
event< T0 > add_timeout (double delay, event< T0 > e)
template<typename T0>
event< T0 > add_timeout_sec (int delay, event< T0 > e)
template<typename T0>
event< T0 > add_timeout_msec (int delay, event< T0 > e)
template<typename T0>
event< T0 > add_signal (int sig, event< T0 > e)
 Add signal interruption to an event.
template<typename T0, typename SigInputIterator>
event< T0 > add_signal (SigInputIterator first, SigInputIterator last, event< T0 > e)
 Add signal interruption to an event.
template<typename T0, typename T1, typename T2, typename T3>
event< T0, T1, T2, T3 > with_timeout (const timeval &delay, event< T0, T1, T2, T3 > e)
 Add silent timeout to an event.
template<typename T0, typename T1, typename T2, typename T3>
event< T0, T1, T2, T3 > with_timeout (double delay, event< T0, T1, T2, T3 > e)
template<typename T0, typename T1, typename T2, typename T3>
event< T0, T1, T2, T3 > with_timeout_sec (int delay, event< T0, T1, T2, T3 > e)
template<typename T0, typename T1, typename T2, typename T3>
event< T0, T1, T2, T3 > with_timeout_msec (int delay, event< T0, T1, T2, T3 > e)
template<typename T0, typename T1, typename T2, typename T3>
event< T0, T1, T2, T3 > with_signal (int sig, event< T0, T1, T2, T3 > e)
 Add silent signal interruption to an event.
template<typename T0, typename T1, typename T2, typename T3, typename SigInputIterator>
event< T0, T1, T2, T3 > with_signal (SigInputIterator first, SigInputIterator last, event< T0, T1, T2, T3 > e)
 Add silent signal interruption to an event.
template<typename T0, typename T1, typename T2, typename T3>
event __with_helper (event< T0, T1, T2, T3 > e, int *result, int value)
template<typename T0, typename T1, typename T2, typename T3>
event< T0, T1, T2, T3 > with_timeout (const timeval &delay, event< T0, T1, T2, T3 > e, int &result)
 Add timeout to an event.
template<typename T0, typename T1, typename T2, typename T3>
event< T0, T1, T2, T3 > with_timeout (double &delay, event< T0, T1, T2, T3 > e, int &result)
template<typename T0, typename T1, typename T2, typename T3>
event< T0, T1, T2, T3 > with_timeout_sec (int delay, event< T0, T1, T2, T3 > e, int &result)
template<typename T0, typename T1, typename T2, typename T3>
event< T0, T1, T2, T3 > with_timeout_msec (int delay, event< T0, T1, T2, T3 > e, int &result)
template<typename T0, typename T1, typename T2, typename T3>
event< T0, T1, T2, T3 > with_signal (int sig, event< T0, T1, T2, T3 > e, int &result)
 Add signal interruption to an event.
template<typename T0, typename T1, typename T2, typename T3, typename SigInputIterator>
event< T0, T1, T2, T3 > with_signal (SigInputIterator first, SigInputIterator last, event< T0, T1, T2, T3 > e, int &result)
 Add signal interruption to an event.
template<typename F>
event fun_event (const F &f)
 Create event that calls a function when triggered.
void initialize ()
 Initializes the Tamer event loop.
timeval & now ()
 Fetches Tamer's current time.
void set_now ()
 Sets Tamer's current time to the current timestamp.
bool driver_empty ()
 Test whether driver events are pending.
void once ()
 Run driver loop once.
void loop ()
 Run driver loop indefinitely.
void at_fd_read (int fd, const event<> &e)
 Register event for file descriptor readability.
void at_fd_read (int fd, const event< int > &e)
void at_fd_write (int fd, const event<> &e)
 Register event for file descriptor writability.
void at_fd_write (int fd, const event< int > &e)
void at_time (const timeval &expiry, const event<> &e)
 Register event for a given time.
void at_delay (const timeval &delay, const event<> &e)
 Register event for a given delay.
void at_delay (double delay, const event<> &e)
 Register event for a given delay.
void at_delay_sec (int delay, const event<> &e)
 Register event for a given delay.
void at_delay_msec (int delay, const event<> &e)
 Register event for a given delay.
void at_signal (int sig, const event<> &e)
 Register event for signal occurrence.
void at_asap (const event<> &e)
 Register event to trigger soon.
template<typename I0, typename I1, typename J0, typename J1, typename T0, typename T1, typename T2, typename T3>
event< T0, T1, T2, T3 > make_event (rendezvous< I0, I1 > &r, const J0 &i0, const J1 &i1, T0 &s0, T1 &s1, T2 &s2, T3 &s3)
 Construct a two-ID, four-slot event on rendezvous r.
template<typename I0, typename J0, typename T0, typename T1, typename T2, typename T3>
event< T0, T1, T2, T3 > make_event (rendezvous< I0 > &r, const J0 &i0, T0 &s0, T1 &s1, T2 &s2, T3 &s3)
template<typename T0, typename T1, typename T2, typename T3>
event< T0, T1, T2, T3 > make_event (rendezvous<> &r, T0 &s0, T1 &s1, T2 &s2, T3 &s3)
template<typename I0, typename I1, typename J0, typename J1, typename T0, typename T1, typename T2>
event< T0, T1, T2 > make_event (rendezvous< I0, I1 > &r, const J0 &i0, const J1 &i1, T0 &s0, T1 &s1, T2 &s2)
template<typename I0, typename J0, typename T0, typename T1, typename T2>
event< T0, T1, T2 > make_event (rendezvous< I0 > &r, const J0 &i0, T0 &s0, T1 &s1, T2 &s2)
template<typename T0, typename T1, typename T2>
event< T0, T1, T2 > make_event (rendezvous<> &r, T0 &s0, T1 &s1, T2 &s2)
template<typename I0, typename I1, typename J0, typename J1, typename T0, typename T1>
event< T0, T1 > make_event (rendezvous< I0, I1 > &r, const J0 &i0, const J1 &i1, T0 &s0, T1 &s1)
template<typename I0, typename J0, typename T0, typename T1>
event< T0, T1 > make_event (rendezvous< I0 > &r, const J0 &i0, T0 &s0, T1 &s1)
template<typename T0, typename T1>
event< T0, T1 > make_event (rendezvous<> &r, T0 &s0, T1 &s1)
template<typename I0, typename I1, typename J0, typename J1, typename T0>
event< T0 > make_event (rendezvous< I0, I1 > &r, const J0 &i0, const J1 &i1, T0 &s0)
template<typename I0, typename J0, typename T0>
event< T0 > make_event (rendezvous< I0 > &r, const J0 &i0, T0 &s0)
template<typename T0>
event< T0 > make_event (rendezvous<> &r, T0 &s0)
template<typename I0, typename I1, typename J0, typename J1>
event make_event (rendezvous< I0, I1 > &r, const J0 &i0, const J1 &i1)
template<typename I0, typename J0>
event make_event (rendezvous< I0 > &r, const J0 &i0)
event make_event (rendezvous<> &r)
bool operator== (const fd &a, const fd &b)
 Test whether two file descriptors refer to the same object.
bool operator!= (const fd &a, const fd &b)
 Test whether two file descriptors refer to the same object.


Detailed Description

Namespace containing public Tamer classes and functions for the Tamer core.

Function Documentation

event tamer::distribute ( const event<> &  e1,
const event<> &  e2 
) [inline]

Create event that triggers e1 and e2 when triggered.

Parameters:
e1 First event.
e2 Second event.
Returns:
Distributer event.
When the distributer event is triggered, e1 and e2 are both triggered instantly. The distributer event is automatically triggered, calling its trigger notifiers, if both e1 and e2 are triggered themselves.

event tamer::distribute ( const event<> &  e1,
const event<> &  e2,
const event<> &  e3 
) [inline]

Create event that triggers e1, e2, and e3 when triggered.

Parameters:
e1 First event.
e2 Second event.
e3 Third event.
Returns:
Distributer event.
Equivalent to distribute(distribute(e1, e2), e3).

template<typename T0, typename V0>
event tamer::bind ( event< T0 >  e,
const V0 &  v0 
)

Create event that triggers e with v0 when triggered.

Parameters:
e Event.
v0 Trigger value.
Returns:
Adapter event.
When the adapter event is triggered, e is triggered instantly with trigger value v0. Conversely, if e triggers first, then the returned event triggers instantly (as can be observed via its at_trigger() notifiers).

template<typename T0>
event< T0 > tamer::unbind ( const event<> &  e  ) 

Create 1-slot event that triggers e when triggered.

Parameters:
e Event.
Returns:
Adapter event.
When the adapter event is triggered, its T0 trigger value is ignored and e is triggered instantly. Conversely, if e triggers first, then the returned event triggers instantly (as can be observed via its at_trigger() notifiers).

template<typename T0>
event<T0> tamer::add_timeout ( const timeval &  delay,
event< T0 >  e 
) [inline]

Add timeout to an event.

Parameters:
delay Timeout duration.
e Event.
Returns:
Adapter event.
Returns an adapter that adds a timeout to e. If the adapter event is triggered before delay time passes, then e is triggered with the same value. If delay time passes first, then e is triggered with value -ETIMEDOUT.

Note:
Versions of this function exist for delay values of types timeval, double, and under the names add_timeout_sec() and add_timeout_msec(), int numbers of seconds and milliseconds, respectively.

template<typename T0>
event<T0> tamer::add_signal ( int  sig,
event< T0 >  e 
) [inline]

Add signal interruption to an event.

Parameters:
sig Signal number.
e Event.
Returns:
Adapter event.
Returns an adapter that adds signal interruption to e. If the adapter event is triggered before signal sig occurs, then e is triggered with the same value. If signal sig occurs first, then e is triggered with value -EINTR.

template<typename T0, typename SigInputIterator>
event<T0> tamer::add_signal ( SigInputIterator  first,
SigInputIterator  last,
event< T0 >  e 
) [inline]

Add signal interruption to an event.

Parameters:
first Input iterator for start of signal collection.
last Input iterator for end of signal collection.
e Event.
Returns:
Adapter event.
Returns an adapter that adds signal interruption to e. If the adapter event is triggered before any of the signals in [first, last) occur, then e is triggered with the same value. If a signal occurs first, then e is triggered with value -EINTR.

template<typename T0, typename T1, typename T2, typename T3>
event<T0, T1, T2, T3> tamer::with_timeout ( const timeval &  delay,
event< T0, T1, T2, T3 >  e 
) [inline]

Add silent timeout to an event.

Parameters:
delay Timeout duration.
e Event.
Returns:
Adapter event.
Returns an adapter that adds a timeout to e. If the adapter event is triggered before the timeout expires, then e is triggered with the same values. If the delay timeout occurs first, then e.bind_all() is triggered, which leaves e's trigger slots unchanged. Conversely, if e is triggered, the returned event is triggered as well (as can be observed via empty() or at_trigger() notifiers).

Note:
Versions of this function exist for delay values of types timeval, double, and under the names with_timeout_sec() and with_timeout_msec(), int numbers of seconds and milliseconds, respectively.

Unlike the add_ adapters, such as add_cancel(), the with_ adapters don't provide any information about whether an event actually triggered. The programmer should use trigger values to distinguish the cases.

template<typename T0, typename T1, typename T2, typename T3>
event<T0, T1, T2, T3> tamer::with_signal ( int  sig,
event< T0, T1, T2, T3 >  e 
) [inline]

Add silent signal interruption to an event.

Parameters:
sig Signal number.
e Event.
Returns:
Adapter event.
Returns an adapter that adds signal interruption to e. If the adapter event is triggered before signal sig occurs, then e is triggered with the same values. If signal sig is received first, then e.bind_all() is triggered, which leaves e's trigger slots unchanged. Conversely, if e is triggered, the returned event is triggered as well.

template<typename T0, typename T1, typename T2, typename T3, typename SigInputIterator>
event<T0, T1, T2, T3> tamer::with_signal ( SigInputIterator  first,
SigInputIterator  last,
event< T0, T1, T2, T3 >  e 
) [inline]

Add silent signal interruption to an event.

Parameters:
first Input iterator for start of signal collection.
last Input iterator for end of signal collection.
e Event.
Returns:
Adapter event.
Returns an adapter that adds signal interruption to e. If the adapter event is triggered before a signal in [first, last) occurs, then e is triggered with the same values. If one of the signals is received first, then e.bind_all() is triggered, which leaves e's trigger slots unchanged. Conversely, if e is triggered, the returned event is triggered as well.

template<typename T0, typename T1, typename T2, typename T3>
event<T0, T1, T2, T3> tamer::with_timeout ( const timeval &  delay,
event< T0, T1, T2, T3 >  e,
int &  result 
) [inline]

Add timeout to an event.

Parameters:
delay Timeout duration.
e Event.
[out] result Result tracker.
Returns:
Adapter event.
Returns an adapter that adds a timeout to e. Initially sets the variable result to 0. If the adapter event is triggered before the timeout expires, then e is triggered with the same values. If the delay seconds pass first, then e.bind_all() is triggered, which leaves e's trigger slots unchanged, and result is immediately set to -ETIMEDOUT. Conversely, if e is triggered, the returned event is triggered as well.

Note:
Versions of this function exist for delay values of types timeval, double, and under the names with_timeout_sec() and with_timeout_msec(), int numbers of seconds and milliseconds, respectively.

template<typename T0, typename T1, typename T2, typename T3>
event<T0, T1, T2, T3> tamer::with_signal ( int  sig,
event< T0, T1, T2, T3 >  e,
int &  result 
) [inline]

Add signal interruption to an event.

Parameters:
sig Signal number.
e Event.
[out] result Result tracker.
Returns:
Adapter event.
Returns an adapter that adds signal interruption to e. Initially sets the variable result to 0. If the adapter event is triggered before signal sig occurs, then e is triggered with the same values. If the signal sig is received first, then e.bind_all() is triggered, which leaves e's trigger slots unchanged, and result is immediately set to -EINTR. Conversely, if e is triggered, the returned event is triggered as well.

template<typename T0, typename T1, typename T2, typename T3, typename SigInputIterator>
event<T0, T1, T2, T3> tamer::with_signal ( SigInputIterator  first,
SigInputIterator  last,
event< T0, T1, T2, T3 >  e,
int &  result 
) [inline]

Add signal interruption to an event.

Parameters:
first Input iterator for start of signal collection.
last Input iterator for end of signal collection.
e Event.
[out] result Result tracker.
Returns:
Adapter event.
Returns an adapter that adds signal interruption to e. Initially sets the variable result to 0. If the adapter event is triggered before a signal in [first, last) occurs, then e is triggered with the same values. If one of the signals is received first, then e.bind_all() is triggered, which leaves e's trigger slots unchanged, and result is immediately set to -EINTR. Conversely, if e is triggered, the returned event is triggered as well.

template<typename F>
event tamer::fun_event ( const F &  f  )  [inline]

Create event that calls a function when triggered.

Parameters:
f Function object.
Returns an event that calls f() immediately when it is triggered. Once the event is completed (triggered or canceled), the f object is destroyed.

Note:
f must have a public copy constructor and a public destructor.

void tamer::initialize (  ) 

Initializes the Tamer event loop.

Must be called at least once before any primitive Tamer events are registered.

timeval& tamer::now (  )  [inline]

Fetches Tamer's current time.

Returns:
Current timestamp.

bool tamer::driver_empty (  )  [inline]

Test whether driver events are pending.

Returns:
True if no driver events are pending, otherwise false.
If driver_empty() is true, then once() will hang forever.

void tamer::at_fd_read ( int  fd,
const event<> &  e 
) [inline]

Register event for file descriptor readability.

Parameters:
fd File descriptor.
e Event.
Triggers e when fd becomes readable. Cancels e when fd is closed.

void tamer::at_fd_write ( int  fd,
const event<> &  e 
) [inline]

Register event for file descriptor writability.

Parameters:
fd File descriptor.
e Event.
Triggers e when fd becomes writable. Cancels e when fd is closed.

void tamer::at_time ( const timeval &  expiry,
const event<> &  e 
) [inline]

Register event for a given time.

Parameters:
expiry Time.
e Event.
Triggers e at timestamp expiry, or soon afterwards.

void tamer::at_delay ( const timeval &  delay,
const event<> &  e 
) [inline]

Register event for a given delay.

Parameters:
delay Delay time.
e Event.
Triggers e when delay seconds have elapsed since now(), or soon afterwards.

void tamer::at_delay ( double  delay,
const event<> &  e 
) [inline]

Register event for a given delay.

Parameters:
delay Delay time.
e Event.
Triggers e when delay seconds have elapsed since now(), or soon afterwards.

void tamer::at_delay_sec ( int  delay,
const event<> &  e 
) [inline]

Register event for a given delay.

Parameters:
delay Delay time.
e Event.
Triggers e when delay seconds have elapsed since now(), or soon afterwards.

void tamer::at_delay_msec ( int  delay,
const event<> &  e 
) [inline]

Register event for a given delay.

Parameters:
delay Delay time in milliseconds.
e Event.
Triggers e when delay milliseconds have elapsed since now(), or soon afterwards.

void tamer::at_signal ( int  sig,
const event<> &  e 
) [inline]

Register event for signal occurrence.

Parameters:
sig Signal number.
e Event.
Triggers e soon after sig is received. The signal sig remains blocked until any code waiting on e has run.

void tamer::at_asap ( const event<> &  e  )  [inline]

Register event to trigger soon.

Parameters:
e Event.
Triggers e the next time through the driver loop.

bool tamer::operator== ( const fd &  a,
const fd &  b 
) [inline]

Test whether two file descriptors refer to the same object.

Parameters:
a First file descriptor.
b Second file descriptor.
Returns:
True iff a and b refer to the same file descriptor.

bool tamer::operator!= ( const fd &  a,
const fd &  b 
) [inline]

Test whether two file descriptors refer to the same object.

Parameters:
a First file descriptor.
b Second file descriptor.
Returns:
True iff a and b do not refer to the same file descriptor.


Generated on Wed Aug 22 17:55:29 2007 for Tamer by  doxygen 1.5.1