Main Page | Alphabetical List | Class List | File List | Class Members | File Members

synchlist.h

Go to the documentation of this file.
00001 // synchlist.h 00002 // Data structures for synchronized access to a list. 00003 // 00004 // Implemented by surrounding the List abstraction 00005 // with synchronization routines. 00006 // 00007 // Copyright (c) 1992-1993 The Regents of the University of California. 00008 // All rights reserved. See copyright.h for copyright notice and limitation 00009 // of liability and disclaimer of warranty provisions. 00010 00011 #ifndef SYNCHLIST_H 00012 #define SYNCHLIST_H 00013 00014 #include "copyright.h" 00015 #include "list.h" 00016 #include "synch.h" 00017 00018 // The following class defines a "synchronized list" -- a list for which: 00019 // these constraints hold: 00020 // 1. Threads trying to remove an item from a list will 00021 // wait until the list has an element on it. 00022 // 2. One thread at a time can access list data structures 00023 00024 class SynchList { 00025 public: 00026 SynchList(); // initialize a synchronized list 00027 ~SynchList(); // de-allocate a synchronized list 00028 00029 void Append(void *item); // append item to the end of the list, 00030 // and wake up any thread waiting in remove 00031 void *Remove(); // remove the first item from the front of 00032 // the list, waiting if the list is empty 00033 // apply function to every item in the list 00034 void Mapcar(VoidFunctionPtr func); 00035 00036 private: 00037 List *list; // the unsynchronized list 00038 Lock *lock; // enforce mutual exclusive access to the list 00039 Condition *listEmpty; // wait in Remove if the list is empty 00040 }; 00041 00042 #endif // SYNCHLIST_H

Generated on Thu Sep 16 12:33:45 2004 for NachOS by doxygen 1.3.8