PHPDaemon\Utils\ShmEntity::write PHP Method

write() public method

Write to shared memory
public write ( string $data, integer $offset ) : boolean
$data string Data
$offset integer Offset
return boolean Success
    public function write($data, $offset)
    {
        $segno = floor($offset / $this->segsize);
        if (!isset($this->segments[$segno])) {
            if (!$this->open($segno, true)) {
                return false;
            }
        }
        $sOffset = $offset % $this->segsize;
        $d = $this->segsize - ($sOffset + mb_orig_strlen($data));
        if ($d < 0) {
            $this->write(mb_orig_substr($data, $d), ($segno + 1) * $this->segsize);
            $data = mb_orig_substr($data, 0, $d);
        }
        //Daemon::log('writing to #'.$offset.' (segno '.$segno.')');
        shmop_write($this->segments[$segno], $data, $sOffset);
        return true;
    }