#include <PsnSemaphore.h>
Inheritance diagram for PsnSemaphore:

Public Methods | |
| PsnSemaphore (const int valeurInitiale) | |
| Constructor. | |
| virtual | ~PsnSemaphore () |
| Destructor. | |
| virtual int | V ()=0 |
| V Increments the semphore value and signals the change to blocked threads. | |
| virtual int | P ()=0 |
| P decrement the sempaphore value and block the calling thread if this value is negative. | |
Definition at line 26 of file PsnSemaphore.h.
|
|
Constructor.
Definition at line 33 of file PsnSemaphore.h.
00033 {};
|
|
|
Destructor.
Definition at line 38 of file PsnSemaphore.h.
00038 {};
|
|
|
P decrement the sempaphore value and block the calling thread if this value is negative.
Implemented in PsnPthreadSemaphore, PsnSequentialSemaphore, and PsnSprocSemaphore. Definition at line 98 of file PsnSemaphore.cxx.
00098 {
00099 int retval,ret;
00100 ret=pthread_mutex_lock(&mutex);
00101 if(ret) {
00102 perror("PsnSemaphore : P a echoue au niveau du mutex lock");
00103 }
00104 v--;
00105 while(v<0) {
00106 ret=pthread_cond_wait(&cond,&mutex);
00107 if(ret) {
00108 perror("PsnSemaphore : P a echoue au niveau du cond");
00109 }
00110 }
00111 retval=v;
00112 ret=pthread_mutex_unlock(&mutex);
00113 if(ret) {
00114 perror("PsnSemaphore : P a echoue au niveau du mutex unlock");
00115 }
00116 return (retval);
00117 }
|
|
|
V Increments the semphore value and signals the change to blocked threads.
Implemented in PsnPthreadSemaphore, PsnSequentialSemaphore, and PsnSprocSemaphore. Definition at line 79 of file PsnSemaphore.cxx.
00079 {
00080 int retval,ret;
00081 ret=pthread_mutex_lock(&mutex);
00082 if(ret) {
00083 perror("PsnSemaphore : V a echoue au niveau du mutex lock");
00084 }
00085 v++;
00086 retval=v;
00087 ret=pthread_mutex_unlock(&mutex);
00088 if(ret) {
00089 perror("PsnSemaphore : V a echoue au niveau du mutex unlock");
00090 }
00091 ret=pthread_cond_signal(&cond);
00092 if(ret) {
00093 perror("PsnSemaphore : V a echoue au niveau du cond");
00094 }
00095 return(retval);
00096 }
|
| Documentation generated on Mon Nov 25 15:26:25 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |