[ RCOS.java Home | RCOS Home | David's Home ]
Name: |
SynchList |
Comment: |
The following class defines a "synchronized list" -- a list for which:
these constraints hold:
|
Collaborators: |
class SynchList {
public:
SynchList(); // initialize a synchronized list
~SynchList(); // de-allocate a synchronized list
void Append(void *item); // append item to the end of the list,
// and wake up any thread waiting in remove
void *Remove(); // remove the first item from the front of
// the list, waiting if the list is empty
// apply function to every item in the list
void Mapcar(VoidFunctionPtr func);
private:
List *list; // the unsynchronized list
Lock *lock; // enforce mutual exclusive access to the list
Condition *listEmpty; // wait in Remove if the list is empty
};