Main Page   Compound List   File List   Compound Members   File Members  

SynchList Class Reference

#include <synchlist.h>

List of all members.

Public Methods

 SynchList ()
 ~SynchList ()
void Append (void *item)
void * Remove ()
void Mapcar (VoidFunctionPtr func)

Private Attributes

Listlist
Locklock
ConditionlistEmpty


Constructor & Destructor Documentation

SynchList::SynchList  
 

Definition at line 25 of file synchlist.cc.

References list, listEmpty, and lock.

00026 {
00027     list = new List();
00028     lock = new Lock("list lock"); 
00029     listEmpty = new Condition("list empty cond");
00030 }

SynchList::~SynchList  
 

Definition at line 37 of file synchlist.cc.

References list, listEmpty, and lock.

00038 { 
00039     delete list; 
00040     delete lock;
00041     delete listEmpty;
00042 }


Member Function Documentation

void SynchList::Append void *    item
 

Definition at line 54 of file synchlist.cc.

References Lock::Acquire, List::Append, list, listEmpty, lock, Lock::Release, and Condition::Signal.

Referenced by MailBox::Put.

00055 {
00056     lock->Acquire();            // enforce mutual exclusive access to the list 
00057     list->Append(item);
00058     listEmpty->Signal(lock);    // wake up a waiter, if any
00059     lock->Release();
00060 }

void SynchList::Mapcar VoidFunctionPtr    func
 

Definition at line 93 of file synchlist.cc.

References Lock::Acquire, list, lock, List::Mapcar, Lock::Release, and VoidFunctionPtr.

00094 { 
00095     lock->Acquire(); 
00096     list->Mapcar(func);
00097     lock->Release(); 
00098 }

void * SynchList::Remove  
 

Definition at line 71 of file synchlist.cc.

References Lock::Acquire, ASSERT, List::IsEmpty, list, listEmpty, lock, NULL, Lock::Release, List::Remove, and Condition::Wait.

Referenced by MailBox::Get.

00072 {
00073     void *item;
00074 
00075     lock->Acquire();                    // enforce mutual exclusion
00076     while (list->IsEmpty())
00077         listEmpty->Wait(lock);          // wait until list isn't empty
00078     item = list->Remove();
00079     ASSERT(item != NULL);
00080     lock->Release();
00081     return item;
00082 }


Member Data Documentation

List* SynchList::list [private]
 

Definition at line 37 of file synchlist.h.

Referenced by Append, Mapcar, Remove, SynchList, and ~SynchList.

Condition* SynchList::listEmpty [private]
 

Definition at line 39 of file synchlist.h.

Referenced by Append, Remove, SynchList, and ~SynchList.

Lock* SynchList::lock [private]
 

Definition at line 38 of file synchlist.h.

Referenced by Append, Mapcar, Remove, SynchList, and ~SynchList.


The documentation for this class was generated from the following files:
Generated on Mon Feb 10 09:54:59 2003 for nachos by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002
The University of Southern California does not screen or control the content on this website and thus does not guarantee the accuracy, integrity, or quality of such content. All content on this website is provided by and is the sole responsibility of the person from which such content originated, and such content does not necessarily reflect the opinions of the University administration or the Board of Trustees