public function send($message, $signal = null, $pause = 500)
    {
        $messageArray = array();

        if (($shmId = @shmop_open($this->pid, 'a', 0, 0)) > 0) {
            // Read any existing messages in shared memory
            $readMessage = shmop_read($shmId, 0, shmop_size($shmId));
            $messageArray[] = unserialize($readMessage);
            shmop_delete($shmId);
            shmop_close($shmId);
        }

        // Add the current message to the end of the array, and serialize it
        $messageArray[] = $message;
        $serializedMessage = serialize($messageArray);

        // Write new serialized message to shared memory
        $shmId = shmop_open($this->pid, 'c', 0644, strlen($serializedMessage));
        if (!$shmId) {
            throw new ProcessControlException(sprintf('Not able to create shared memory segment for PID: %s', $this->pid));
        } else if (shmop_write($shmId, $serializedMessage, 0) !== strlen($serializedMessage)) {
            throw new ProcessControlException(
                sprintf('Not able to write message to shared memory segment for segment ID: %s', $shmId)
            );
        }

        if (false === $signal) {
            return;
        }

        $this->signal($signal ?: $this->signal);
        usleep($pause);
    }
public function send($message, $signal = null, $pause = 500)
    {
        $messageArray = array();

        if (($shmId = @shmop_open($this->pid, 'a', 0, 0)) > 0) {
            // Read any existing messages in shared memory
            $readMessage = shmop_read($shmId, 0, shmop_size($shmId));
            $messageArray[] = unserialize($readMessage);
            shmop_delete($shmId);
            shmop_close($shmId);
        }

        // Add the current message to the end of the array, and serialize it
        $messageArray[] = $message;
        $serializedMessage = serialize($messageArray);

        // Write new serialized message to shared memory
        $shmId = shmop_open($this->pid, 'c', 0644, strlen($serializedMessage));
        if (!$shmId) {
            throw new ProcessControlException(sprintf('Not able to create shared memory segment for PID: %s', $this->pid));
        } else if (shmop_write($shmId, $serializedMessage, 0) !== strlen($serializedMessage)) {
            throw new ProcessControlException(
                sprintf('Not able to write message to shared memory segment for segment ID: %s', $shmId)
            );
        }

        if (false === $signal) {
            return;
        }

        $this->signal($signal ?: $this->signal);
        usleep($pause);
    }
public function send ( $ message , $ signal = null , $ pause = 500 ) { $ messageArray = array ( ) ; if ( ( $ shmId = @ shmop_open ( $ this -> pid , 'a' , 0 , 0 ) ) > 0 ) { // Read any existing messages in shared memory $ readMessage = shmop_read ( $ shmId , 0 , shmop_size ( $ shmId ) ) ; $ messageArray [ ] = unserialize ( $ readMessage ) ; shmop_delete ( $ shmId ) ; shmop_close ( $ shmId ) ; } // Add the current message to the end of the array, and serialize it $ messageArray [ ] = $ message ; $ serializedMessage = serialize ( $ messageArray ) ; // Write new serialized message to shared memory $ shmId = shmop_open ( $ this -> pid , 'c' , 0644 , strlen ( $ serializedMessage ) ) ; if ( ! $ shmId ) { throw new ProcessControlException ( sprintf ( 'Not able to create shared memory segment for PID: %s' , $ this -> pid ) ) ; } else if ( shmop_write ( $ shmId , $ serializedMessage , 0 ) !== strlen ( $ serializedMessage ) ) { throw new ProcessControlException ( sprintf ( 'Not able to write message to shared memory segment for segment ID: %s' , $ shmId ) ) ; } if ( false === $ signal ) { return ; } $ this -> signal ( $ signal ? : $ this -> signal ) ; usleep ( $ pause ) ; }
Writes a message to the shared memory.

@param mixed   $message The message to send
@param integer $signal  The signal to send afterward
@param integer $pause   The number of microseconds to pause after signalling
Writes a message to the shared memory .