Пример #1
0
 /**
  * Create a new receiver.
  * 
  * @param \Spawn\Process $process The process singleton.
  * @param string $class_name The class to instantiate.
  * @param array $arguments The arguments to pass to the class constructor.s
  * @param string The path of this process' FIFO input pipe.
  * @param string The path of this process' FIFO output pipe.
  */
 public function __construct(\Spawn\Process $process, \Spawn\Pipeline $pipeline, $class_name, $arguments)
 {
     $this->process = $process;
     $this->pipeline = $pipeline;
     // Create instance of passed class.
     $reflection = new \ReflectionClass($class_name);
     $this->instance = $reflection->newInstanceArgs($arguments);
     // Initialise I/O queues.
     $this->rpc_queue = array();
     $this->response_queue = array();
     // Initialise I/O watchers.
     $pipeline->openInChild();
     $loop = $this->process->loop;
     $this->watchers = array($loop->io($pipeline->request_fd, \Ev::READ, array($this, '_onReceiverInReadable')), $loop->io($pipeline->response_fd, \Ev::WRITE, array($this, '_onReceiverOutWritable')), $loop->idle(array($this, '_onIdle')));
 }