Page principale | Liste des namespaces | Hiérarchie des classes | Liste des classes | Répertoires | Liste des fichiers | Membres de namespace | Membres de classe | Membres de fichier

synchlist.h

Aller à la documentation de ce fichier.
00001 // synchlist.h 
00002 //      Data structures for synchronized access to a list.
00003 //
00004 //      Identical interface to List, except accesses are synchronized.
00005 //
00006 // Copyright (c) 1992-1996 The Regents of the University of California.
00007 // All rights reserved.  See copyright.h for copyright notice and limitation 
00008 // of liability and disclaimer of warranty provisions.
00009 
00010 #ifndef SYNCHLIST_H
00011 #define SYNCHLIST_H
00012 
00013 #include "copyright.h"
00014 #include "list.h"
00015 #include "synch.h"
00016 
00017 // The following class defines a "synchronized list" -- a list for which
00018 // these constraints hold:
00019 //      1. Threads trying to remove an item from a list will
00020 //      wait until the list has an element on it.
00021 //      2. One thread at a time can access list data structures
00022 
00023 template <class T>
00024 class SynchList {
00025   public:
00026     SynchList();                // initialize a synchronized list
00027     ~SynchList();               // de-allocate a synchronized list
00028 
00029     void Append(T item);        // append item to the end of the list,
00030                                 // and wake up any thread waiting in remove
00031 
00032     T RemoveFront();            // remove the first item from the front of
00033                                 // the list, waiting if the list is empty
00034 
00035     void Apply(void (*f)(T)); // apply function to all elements in list
00036 
00037     void SelfTest(T value);     // test the SynchList implementation
00038     
00039   private:
00040     List<T> *list;              // the list of things
00041     Lock *lock;                 // enforce mutual exclusive access to the list
00042     Condition *listEmpty;       // wait in Remove if the list is empty
00043     
00044     // these are only to assist SelfTest()
00045     SynchList<T> *selfTestPing;
00046     static void SelfTestHelper(void* data);
00047 };
00048 
00049 #include "synchlist.cc"
00050 
00051 #endif // SYNCHLIST_H

Généré le Sun Jan 15 00:45:45 2006 pour Système NachOS : par  doxygen 1.4.4