Microthread Class Reference

This class defines an interface and necessary methods for Microthreads. More...

#include <microthread.h>

Inheritance diagram for Microthread:

NewCoroutine Coroutine RefCounter BaseScheduler EpollScheduler SelectScheduler List of all members.

Public Member Functions

virtual void run ()=0
 This method is run when the Microthread gets started.
void scheduleme ()
 Schedule this Microthread for continuation.
void delayme ()
 Discontinues executing this Microthread for now.
void swapto (Microthread &o, bool acquired=false)
 Discontinues executing this Microthread and continue execution of the Microthread o.
void setcallback (Callback *cb)
 Sets a Callback to be executed at the next time this Microthread continues execution.

Public Attributes

ChannelManager channelmanager
 Manager object for channels associated with this microthread.

Protected Member Functions

 Microthread (BlockingQueue< Microthread * > *q=NULL)
 Construct a Microthread running on queue q.
void start ()
 Boots the Microthread.

Protected Attributes

BlockingQueue< Microthread * > & queue
 The queue to be used with scheduleme().

Friends

class Runner

Detailed Description

This class defines an interface and necessary methods for Microthreads.


Constructor & Destructor Documentation

Microthread::Microthread ( BlockingQueue< Microthread * > *  q = NULL  )  [protected]

Construct a Microthread running on queue q.

Parameters:
q is the queue the Microthread needs to insert itself


Member Function Documentation

virtual void Microthread::run (  )  [pure virtual]

This method is run when the Microthread gets started.

It must be overridden by all derived classes.

Implemented in BaseScheduler, EpollScheduler, and SelectScheduler.

void Microthread::scheduleme (  )  [inline]

Schedule this Microthread for continuation.

If this Microthread currently runs it should immediately call .delayme().

void Microthread::delayme (  ) 

Discontinues executing this Microthread for now.

It may later be continued by scheduleme() or special swapto() calls.

Exceptions:
ThreadExitException 

void Microthread::swapto ( Microthread o,
bool  acquired = false 
)

Discontinues executing this Microthread and continue execution of the Microthread o.

Apart from directly passing control to o this works like delayme().

Parameters:
o is the Microthread to be continued
acquired the internal lock is not acquired of this is set to true, ignore this if you don't know about internal locks
Exceptions:
ThreadExitException 

void Microthread::setcallback ( Callback cb  ) 

Sets a Callback to be executed at the next time this Microthread continues execution.

The Callback will be executed within this Microthread and thus may throw exceptions to terminate the Microthread.

Parameters:
cb is the callback to be executed


Member Data Documentation

BlockingQueue<Microthread*>& Microthread::queue [protected]

The queue to be used with scheduleme().

This is internal and should not be used. It is not private because it is used in scheduler implementations.

ChannelManager Microthread::channelmanager

Manager object for channels associated with this microthread.

It should be passed to the Channel constructor.


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