Jamm\Memory\Shm\SHMObject::set_ID PHP Метод

set_ID() публичный Метод

public set_ID ( $ID )
    public function set_ID($ID)
    {
        if (!empty($ID)) {
            $this->id = $ID;
        }
        //Create Mutex ("multiple read, one write")
        $this->mutex = new MultiAccess($this->id);
        //Create "shmop" to store data
        $this->shm_data_key = ftok($this->id, 'D');
        //D - Data. But I still love my son Nikita ;)
        $this->shm_data_id = @shmop_open($this->shm_data_key, "w", 0, 0);
        if (!$this->shm_data_id) {
            $this->shm_data_id = @shmop_open($this->shm_data_key, "a", 0, 0);
            if ($this->shm_data_id !== false) {
                $this->readonly = true;
            }
        }
        //if memory not yet exists - lets create
        if (!$this->shm_data_id) {
            $this->shm_data_id = shmop_open($this->shm_data_key, "n", 0777, $this->max_size);
        }
        if (!$this->shm_data_id) {
            $this->ReportError('Can not create data segment in shared memory', __LINE__);
            return false;
        }
        //Create an mem-object to store the Map
        $map_id_key = ftok($this->id, 'h') + 12;
        $this->mem_object = new ShmMem($map_id_key, $this->shmsize, $this->max_size);
        if (!is_object($this->mem_object)) {
            $this->ReportError('Can not create map', __LINE__);
            return false;
        }
        return true;
    }