|
Last change
on this file since 3177 was 1016, checked in by ansari, 25 years ago |
|
Creation du module JThreadsC++, importation du code des classes
de Thread a la Java de Object Oriented Concepts Inc - Reza 19/5/2000
|
|
File size:
1.5 KB
|
| Rev | Line | |
|---|
| [1016] | 1 | // **********************************************************************
|
|---|
| 2 | //
|
|---|
| 3 | // Copyright (c) 2000
|
|---|
| 4 | // Object Oriented Concepts, Inc.
|
|---|
| 5 | // Billerica, MA, USA
|
|---|
| 6 | //
|
|---|
| 7 | // All Rights Reserved
|
|---|
| 8 | //
|
|---|
| 9 | // **********************************************************************
|
|---|
| 10 |
|
|---|
| 11 | #ifndef JTC_COND_H
|
|---|
| 12 | #define JTC_COND_H
|
|---|
| 13 |
|
|---|
| 14 | //
|
|---|
| 15 | // This class acts like a pthreads condition variable. The difference
|
|---|
| 16 | // is that this implementation works with the recursive mutex
|
|---|
| 17 | // implementation in this library.
|
|---|
| 18 | //
|
|---|
| 19 | class JTCCond
|
|---|
| 20 | {
|
|---|
| 21 | //
|
|---|
| 22 | // Actual implementation of wait.
|
|---|
| 23 | //
|
|---|
| 24 | void _wait(long timeout);
|
|---|
| 25 |
|
|---|
| 26 | //
|
|---|
| 27 | // Hide copy constructor and assignment operator.
|
|---|
| 28 | //
|
|---|
| 29 | JTCCond(const JTCCond&);
|
|---|
| 30 | void operator=(const JTCCond&);
|
|---|
| 31 |
|
|---|
| 32 | JTCRecursiveMutex& mutex_; // Associated mutex.
|
|---|
| 33 | #if defined(HAVE_POSIX_THREADS) || defined(HAVE_DCE_THREADS)
|
|---|
| 34 | pthread_cond_t cond_; // Pthread condition variable.
|
|---|
| 35 | #endif
|
|---|
| 36 |
|
|---|
| 37 | #if defined(HAVE_WIN32_THREADS)
|
|---|
| 38 | DWORD waiters_; // Number of waiters.
|
|---|
| 39 | HANDLE sema_; // Handle to WIN32 sempahore object.
|
|---|
| 40 | JTCMutex waitersMutex_;
|
|---|
| 41 | JTCEvent broadcastEvent_;
|
|---|
| 42 | bool haveBroadcast_;
|
|---|
| 43 | #endif
|
|---|
| 44 |
|
|---|
| 45 | public:
|
|---|
| 46 |
|
|---|
| 47 | JTCCond(JTCRecursiveMutex& mut);
|
|---|
| 48 | ~JTCCond();
|
|---|
| 49 |
|
|---|
| 50 | //
|
|---|
| 51 | // Wait for the condition variable to be signalled.
|
|---|
| 52 | // The mutex has to be set.
|
|---|
| 53 | //
|
|---|
| 54 | void wait(long timeout);
|
|---|
| 55 |
|
|---|
| 56 | //
|
|---|
| 57 | // Wait for the condition variable to be signalled.
|
|---|
| 58 | // The mutex has to be set.
|
|---|
| 59 | //
|
|---|
| 60 | void wait();
|
|---|
| 61 |
|
|---|
| 62 | //
|
|---|
| 63 | // Signal one waiting thread.
|
|---|
| 64 | //
|
|---|
| 65 | void signal();
|
|---|
| 66 |
|
|---|
| 67 | //
|
|---|
| 68 | // Signal all waiting threads.
|
|---|
| 69 | //
|
|---|
| 70 | void broadcast();
|
|---|
| 71 | };
|
|---|
| 72 |
|
|---|
| 73 | #endif
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.