tac0S
Template Affectional Command Operating System
synchlist.h
Go to the documentation of this file.
1 
14 #ifndef SYNCHLIST_H
15 #define SYNCHLIST_H
16 
17 #include "copyright.h"
18 #include "list.h"
19 #include "synch.h"
20 
26 
27 class SynchList
28 {
29  public:
30  SynchList (); // initialize a synchronized list
31  ~SynchList (); // de-allocate a synchronized list
32 
33  void Append (void *item); // append item to the end of the list,
34  // and wake up any thread waiting in remove
35  void *Remove (); // remove the first item from the front of
36  // the list, waiting if the list is empty
37  // apply function to every item in the list
38  void Mapcar (VoidFunctionPtr func);
39 
40 
41  void * get(unsigned int index);
42  unsigned int size();
43 
44 
45  // Acquire the current Lock
46  void GetTheLock();
47  // Release the current Lock
48  void FreeTheLock();
49  // Return the list
50  List * getList();
51  // Return true if empty
52  bool IsEmpty();
53 
54 
55  private:
56  List * list; // the unsynchronized list
57  Lock *lock; // enforce mutual exclusive access to the list
58  Condition *listEmpty; // wait in Remove if the list is empty
59 };
60 
61 #endif // SYNCHLIST_H
unsigned int size()
SynchList::size Return the size of the current list.
Definition: synchlist.cc:128
void GetTheLock()
SynchList::GetTheLock Execute an acquire to the lock, then the kernel could use the list for thread m...
Definition: synchlist.cc:142
List * getList()
SynchList::getList Return the list, for thread management utilisation.
Definition: synchlist.cc:162
Definition: list.h:46
~SynchList()
SynchList::~SynchList De-allocate the data structures created for synchronizing a list...
Definition: synchlist.cc:39
Routines to manage a singly-linked list of "things". Defining TRUE and FALSE is usually a Bad Idea...
void Append(void *item)
SynchList::Append Append an "item" to the end of the list. Wake up anyone waiting for an element to b...
Definition: synchlist.cc:56
bool IsEmpty()
SynchList::IsEmpty Know if the synchlist is empty or not.
Definition: synchlist.cc:169
SynchList()
SynchList::SynchList Allocate and initialize the data structures needed for a synchronized list...
Definition: synchlist.cc:27
void Mapcar(VoidFunctionPtr func)
SynchList::Mapcar Apply function to every item on the list. Obey mutual exclusion constraints...
Definition: synchlist.cc:95
void FreeTheLock()
SynchList::FreeTheLock Execute a release to the lock, then the kernel stop use the list for thread ma...
Definition: synchlist.cc:152
Data structures for synchronizing threads.
void * Remove()
SynchList::Remove Remove an "item" from the beginning of the list. Wait if the list is empty...
Definition: synchlist.cc:73
The following class defines a "synchronized list" – a list for which: these constraints hold: ...
Definition: synchlist.h:27
Definition: synch.h:73
Definition: synch.h:131