Example #1
5
 function enableForConsumer($consumerId, $interval, $probeKey)
 {
     $_this = $this;
     $this->enabled = true;
     if (!$this->instant) {
         // register consumer
         $newConsumerId = !isset($this->consumerTimers[$consumerId]);
         if ($interval > 0 && $newConsumerId) {
             $this->consumerTimers[$consumerId] = setInterval(function () use($_this, $consumerId) {
                 $_this->sample($consumerId);
             }, $interval);
         }
         // enable with delayed disabling
         if (!empty($this->disableDelay)) {
             clearTimeout($this->disableDelay);
         }
         $this->disableDelay = setTimeout(function () use($_this) {
             //echo "\ndisabled " . $_this->name;
             $_this->enabled = false;
             foreach ($_this->consumerTimers as $consumerId => $timer) {
                 clearInterval($timer);
             }
             $_this->consumerTimers = array();
         }, PROBE_DISABLE_DELAY);
     }
 }
Example #2
0
 /**
  * Free the object
  */
 public function free()
 {
     clearTimeout($this->reloadCheckTimer);
     $this->removeAll();
 }