class GMonitor

Monitor class.

Inheritance:


Public Methods

[more] GMonitorLock(GMonitor *gsec)
Enters the monitor.
[more] ~GMonitorLock()
Destructor.


Documentation

Monitor class. Monitors have been first described in (C.A.R Hoare, Communications of the ACM, 17(10), 1974). This mechanism provides the basic mutual exclusion (mutex) and thread notification facilities (condition variables).

Only one thread can own the monitor at a given time. Functions enter and leave can be used to acquire and release the monitor. This mutual exclusion provides an efficient way to protect segment of codes (critical sections) which should not be simultaneously executed by two threads. Class GMonitorLock provides a convenient way to do this effectively.

When the thread owning the monitor calls function wait, the monitor is released and the thread starts waiting until another thread calls function signal or broadcast. When the thread wakes-up, it re-acquires the monitor and function wait returns. Since the signaling thread must acquire the monitor before calling functions signal and broadcast, the signaled thread will not be able to re-acquire the monitor until the signaling thread(s) releases the monitor.

Note --- Both the copy constructor and the copy operator are declared as private members. It is therefore not possible to make multiple copies of instances of this class, as implied by the class semantic.

o GMonitorLock(GMonitor *gsec)
Enters the monitor. If the monitor is acquired by another thread this function waits until the monitor is released. The current thread then acquires the monitor. Calls to void enter();

void leave();

void wait();

void wait(unsigned long timeout);

void signal();

void broadcast(); private:

int ok; int count; DWORD locker; CRITICAL_SECTION cs; struct thr_waiting *head; struct thr_waiting *tail;

int ok; int count; unsigned long locker; int wlock; int wsig;

int ok; int count; pthread_t locker; pthread_mutex_t mutex; pthread_cond_t cond;

int ok; int count; void *locker; int wlock; int wsig;

JRIGlobalRef obj;

private: GMonitor(const GMonitor&); GMonitor& operator=(const GMonitor&); };

inline GThread::GThread(int stacksize) {} inline GThread::~GThread(void) {} inline void GThread::terminate() {} inline int GThread::yield() { return 0; } inline void* GThread::current() { return 0; } inline GMonitor::GMonitor() {} inline GMonitor::~GMonitor() {} inline void GMonitor::enter() {} inline void GMonitor::leave() {} inline void GMonitor::wait() {} inline void GMonitor::wait(unsigned long timeout) {} inline void GMonitor::signal() {} inline void GMonitor::broadcast() {}

class GMonitorLock { private: GMonitor *gsec; public: /** Constructor. Enters the monitor gsec.

o ~GMonitorLock()
Destructor. Leaves the associated monitor.


Direct child classes:
GSafeFlags

Alphabetic index HTML hierarchy of classes or Java


DjVu is a trademark of LizardTech, Inc.
All other products mentioned are registered trademarks or trademarks of their respective companies.