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

SynchList Class Template Reference

The following class defines a "synchronized list" -- a list for which these constraints hold: 1. Threads trying to remove an item from a list will wait until the list has an element on it. 2. One thread at a time can access list data structures. More...

#include <synchlist.h>

List of all members.

Public Methods

 SynchList ()
 initialize a synchronized list. More...

 ~SynchList ()
 de-allocate a synchronized list. More...

void Append (T item)
 append item to the end of the list, and wake up any thread waiting in remove. More...

RemoveFront ()
 remove the first item from the front of the list, waiting if the list is empty. More...

void Apply (void(*f)(T))
 apply function to all elements in list. More...

void SelfTest (T value)
 test the SynchList implementation. More...


Private Methods

void SelfTestHelper ()
 only to assist SelfTest(). More...


Private Attributes

List<T>* list
 the list of things. More...

Locklock
 enforce mutual exclusive access to the list. More...

ConditionlistEmpty
 wait in Remove if the list is empty. More...

SynchList<T>* selfTestPing
 only to assist SelfTest(). More...


Detailed Description

template<class T> class SynchList

The following class defines a "synchronized list" -- a list for which these constraints hold: 1. Threads trying to remove an item from a list will wait until the list has an element on it. 2. One thread at a time can access list data structures.

Definition at line 24 of file synchlist.h.


Constructor & Destructor Documentation

template<class T>
SynchList<T>::SynchList<T> ( )
 

initialize a synchronized list.

SynchList<T>::SynchList Allocate and initialize the data structures needed for a synchronized list, empty to start with. Elements can now be added to the list.

Definition at line 23 of file synchlist.cc.

template<class T>
SynchList<T>::~SynchList<T> ( )
 

de-allocate a synchronized list.

SynchList<T>~SynchList De-allocate the data structures created for synchronizing a list.

Definition at line 36 of file synchlist.cc.


Member Function Documentation

template<class T>
void SynchList<T>::Append ( T item )
 

append item to the end of the list, and wake up any thread waiting in remove.

SynchList<T>::Append Append an "item" to the end of the list. Wake up anyone waiting for an element to be appended.

"item" is the thing to put on the list.

Definition at line 53 of file synchlist.cc.

Referenced by MailBox::Put(), SelfTest(), and SelfTestHelper().

template<class T>
void SynchList<T>::Apply ( void(* f)(T) )
 

apply function to all elements in list.

SynchList<T>::Apply Apply function to every item on a list.

"func" -- the function to apply

Definition at line 92 of file synchlist.cc.

template<class T>
T SynchList<T>::RemoveFront ( )
 

remove the first item from the front of the list, waiting if the list is empty.

SynchList<T>::RemoveFront Remove an "item" from the beginning of the list. Wait if the list is empty.

Returns: The removed item.

Definition at line 71 of file synchlist.cc.

Referenced by MailBox::Get(), and SelfTestHelper().

template<class T>
void SynchList<T>::SelfTest ( T value )
 

test the SynchList implementation.

Definition at line 117 of file synchlist.cc.

Referenced by ThreadedKernel::SelfTest().

template<class T>
void SynchList<T>::SelfTestHelper ( ) [private]
 

only to assist SelfTest().

SynchList<T>::SelfTest, SelfTestHelper Test whether the SynchList implementation is working, by having two threads ping-pong a value between them using two synchronized lists.

Definition at line 108 of file synchlist.cc.


Member Data Documentation

template<class T>
List< T > * SynchList<T>::list<T> [private]
 

the list of things.

Definition at line 40 of file synchlist.h.

template<class T>
Condition * SynchList<T>::listEmpty [private]
 

wait in Remove if the list is empty.

Definition at line 42 of file synchlist.h.

template<class T>
Lock * SynchList<T>::lock [private]
 

enforce mutual exclusive access to the list.

Definition at line 41 of file synchlist.h.

template<class T>
SynchList< T > * SynchList<T>::selfTestPing<T> [private]
 

only to assist SelfTest().

Definition at line 45 of file synchlist.h.


The documentation for this class was generated from the following files:
Generated at Wed Jul 4 11:32:24 2001 for Nachos by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001