#include <Semaphores.h>
Collaboration diagram for PLearn::ResourceSemaphore:

Public Member Functions | |
| ResourceSemaphore (int nb_semaphores=1) | |
| construct given number of semaphores for controlling so many exclusive resources.   | |
| ResourceSemaphore (SemId semid) | |
| access an existing semaphore   | |
| void | lock (int resource=0) | 
| void | unlock (int resource=0) | 
| Release a lock on a resource.   | |
| bool | locked (int resource=0) | 
| to check without waiting wether a resource is locked.   | |
| void | clearAnyLock () | 
| make sure we are back in unlocked mode: clear locks of all resources   | |
| void | clearAnyLock (int resource) | 
| make sure we are back in unlocked mode: clear lock for given resource   | |
| ~ResourceSemaphore () | |
| release the semaphore upon destruction of object   | |
Protected Attributes | |
| SemId | id | 
| semaphore id provided by the operating system at construction   | |
| bool | owner | 
| true if this process is the owner of the semaphore, i.e   | |
| int | n_semaphores | 
| there can be several semaphores in the same object   | |
      
  | 
  
| 
 construct given number of semaphores for controlling so many exclusive resources. 
 Definition at line 49 of file Semaphores.cc. References clearAnyLock(), PLearn::endl(), n_semaphores, and PLERROR.  | 
  
      
  | 
  
| 
 access an existing semaphore 
 Definition at line 62 of file Semaphores.cc. References n_semaphores, and PLERROR.  | 
  
      
  | 
  
| 
 release the semaphore upon destruction of object 
 Definition at line 124 of file Semaphores.cc. References PLearn::endl(), owner, PLERROR, and PLearn::semun::val.  | 
  
      
  | 
  
| 
 make sure we are back in unlocked mode: clear lock for given resource 
 Definition at line 114 of file Semaphores.cc. References PLERROR, and PLearn::semun::val.  | 
  
      
  | 
  
| 
 make sure we are back in unlocked mode: clear locks of all resources 
 Definition at line 108 of file Semaphores.cc. References n_semaphores. Referenced by ResourceSemaphore().  | 
  
      
  | 
  
| 
 Wait for a resource to be freed and then take control of it. This is done by waiting for the resource semaphore's to become 1 and then decrementing its value to 0 (thus taking the lock). Definition at line 74 of file Semaphores.cc. References PLERROR.  | 
  
      
  | 
  
| 
 to check without waiting wether a resource is locked. 
 Definition at line 101 of file Semaphores.cc. References PLearn::semun::val. Referenced by unlock().  | 
  
      
  | 
  
| 
 Release a lock on a resource. This is done by incrementing the resource's semaphore. No waiting. Definition at line 86 of file Semaphores.cc.  | 
  
      
  | 
  
| 
 semaphore id provided by the operating system at construction 
 Definition at line 96 of file Semaphores.h.  | 
  
      
  | 
  
| 
 there can be several semaphores in the same object 
 Definition at line 99 of file Semaphores.h. Referenced by clearAnyLock(), and ResourceSemaphore().  | 
  
      
  | 
  
| 
 true if this process is the owner of the semaphore, i.e the semaphore will be released with this object is deleted Definition at line 97 of file Semaphores.h. Referenced by ~ResourceSemaphore().  | 
  
 1.3.7