The routine class is used by the processor during the routine calculation for storing the idle functions and the signals which should be triggered in the next loop. This was added due to the current loop not providing a simple means for objects inside the loop determining what has happened within the routine calculation and the functionality required for the upgraded idle required more complex algorithms which would not fit well inside the entire routine loop method.
示例#1
0
 /**
  * Runs the routine.
  *
  * This checks if the appriorate amount of time has passed and emits the 
  * awake signal if so.
  * 
  * @return  boolean
  */
 public function routine(\XPSPL\Routine $routine = null)
 {
     if ($this->get_idle()->has_time_passed()) {
         $routine->add_signal($this);
         $this->get_idle()->set_time($this->_time);
     }
     $routine->add_idle($this);
     return true;
 }
示例#2
0
 /**
  * Routine function.
  */
 public function routine(\XPSPL\Routine $routine)
 {
     if (null === $this->_test) {
         return false;
     }
     $routine->add_signal($this);
     $routine->add_signal($this->_test);
     $this->_test = null;
     return true;
 }
示例#3
0
文件: sig_cron.php 项目: prggmr/xpspl
 /**
  * Determines when the time signal should fire, otherwise returning
  * the processor to idle until it will.
  * 
  * @return  integer
  */
 public function routine(\XPSPL\Routine $routine = null)
 {
     if ($this->get_idle()->has_time_passed()) {
         $this->_next_run = $this->_cron->getNextRunDate()->getTimestamp();
         $routine->add_signal($this);
     }
     $this->get_idle()->set_time($this->_next_run - time());
     $routine->add_idle($this);
     return true;
 }
示例#4
0
文件: socket.php 项目: prggmr/xpspl
 /**
  * Registers the idle process.
  *
  * @return  void
  */
 public function routine(\XPSPL\Routine $routine)
 {
     if (null === $this->_connection) {
         $this->_connect();
         $routine->add_signal(new SIG_Connect($this->_connection));
     }
     $routine->add_idle($this);
 }
示例#5
0
文件: sig_test.php 项目: prggmr/xpspl
 /**
  * Runs the routine.
  */
 public function routine(\XPSPL\Routine $routine)
 {
     if (!$this->_run) {
         $this->_run = true;
         $routine->add_signal($this);
     }
 }
示例#6
0
文件: routine.php 项目: prggmr/xpspl
 /**
  * Run the idle function.
  */
 public function routine(\XPSPL\Routine $routine)
 {
     // TODO - Add function to fetch lowest idle time
     $routine->add_idle($this);
 }
示例#7
0
 public function routine(\XPSPL\Routine $routine)
 {
     if (count($this->_files) > 0 || count($this->_uploading) > 0) {
         $routine->add_idle($this);
     }
 }