Suspender< T > Class Template Reference

Suspends a Microthread and lets many others wake it. More...

#include <suspender_decls.h>

Inheritance diagram for Suspender< T >:

RefCounter List of all members.

Public Member Functions

suspend ()
 Suspends the current Microthread until another Microthread invokes the wakeup() method.
bool wakeup (const T &rv)
 Tries to wake the suspended Microthread with rv as return value.
bool cooperativewakeup (const T &rv)
 Does the same as wakeup() with a direct context switch.
bool issuspended () const
 Checks whether a Microthread is currently suspended by this Suspender.
bool iswakened () const
 Checks whether wakeup() was called.
bool iscompleted () const
 Checks whether both suspend() and wakeup() are called.

Static Public Member Functions

static Suspendercreate ()
 This method wraps the constructor to make sure new is used.

Detailed Description

template<class T>
class Suspender< T >

Suspends a Microthread and lets many others wake it.

A Microthread gives references to Suspender objects to other Microthread and invokes the suspend() method. The first Microthread that invokes the wakeup(object) method wakes the suspended Microthread. All other calls are ignored.


Member Function Documentation

template<class T>
static Suspender& Suspender< T >::create (  )  [inline, static]

This method wraps the constructor to make sure new is used.

Returns:
the new Suspender object

template<class T>
T Suspender< T >::suspend (  ) 

Suspends the current Microthread until another Microthread invokes the wakeup() method.

Returns:
the argument passed to wakeup()

template<class T>
bool Suspender< T >::wakeup ( const T &  rv  ) 

Tries to wake the suspended Microthread with rv as return value.

Parameters:
rv is returned by suspend() in the suspended Microthread
Returns:
true if this call really wakes the suspended Microthread

template<class T>
bool Suspender< T >::cooperativewakeup ( const T &  rv  ) 

Does the same as wakeup() with a direct context switch.

See also:
wakeup
Parameters:
rv is returned by suspend() in the suspended Microthread
Returns:
true if this call really wakes the suspended Microthread

template<class T>
bool Suspender< T >::issuspended (  )  const [inline]

Checks whether a Microthread is currently suspended by this Suspender.

Returns:
true a Microthread called suspend and no other called wakeup() yet

template<class T>
bool Suspender< T >::iswakened (  )  const [inline]

Checks whether wakeup() was called.

Returns:
true if any Microthread called wakeup()

template<class T>
bool Suspender< T >::iscompleted (  )  const [inline]

Checks whether both suspend() and wakeup() are called.

Returns:
true if there was a suspended Microthread that already woke up


The documentation for this class was generated from the following files:
Generated on Sat Feb 7 01:26:51 2009 by  doxygen 1.5.1