예제 #1
0
 /**
  * Initialize a semaphore that can be handled by the
  * functions provided by this class.
  * @throws ParamNotValidException
  * @return true if loading the semaphore was successful
  */
 public function load($sem = null)
 {
     if (strncmp(gettype($sem), "object", 6) == 0 && strncmp(get_class($sem), "core\\control\\Semaphore", strlen(get_class($sem))) == 0) {
         $this->semaphore = $sem;
         $this->semaphore->create();
         return true;
     } else {
         $this->log(__METHOD__ . ": %", array(new ParamNotValidException("sem(core\\control\\Semaphore)=" . StringUtil::get_object_value($sem))));
         throw new ParamNotValidException("sem(core\\control\\Semaphore)=" . StringUtil::get_object_value($sem));
     }
 }
예제 #2
0
 /**
  * Pin a semaphore onto this shared memory segment to protect
  * write access.
  * @param $sem a valid semaphore
  * @throws ParamNotValidException
  * @see Semaphore
  * @see SharedMemoryHandler
  */
 public function set_shm_seg_sem_write($sem = null)
 {
     if (strncmp(gettype($sem), "object", 6) == 0 && strncmp(get_class($sem), "core\\control\\Semaphore", 22) == 0) {
         $this->shm_seg_sem_write = $sem;
     } else {
         $this->shm_seg_sem_write = null;
         //throw ParamNotValidException
         $this->log(__METHOD__ . ": %", array(new ParamNotValidException("sem(core\\control\\Semaphore)=" . StringUtil::get_object_value($sem))));
         throw new ParamNotValidException("sem(core\\control\\Semaphore)=" . StringUtil::get_object_value($sem));
     }
 }