Icicle\Concurrent\Sync\PosixSemaphore::init PHP Method

init() private method

private init ( integer $maxLocks, integer $permissions )
$maxLocks integer The maximum number of locks that can be acquired from the semaphore.
$permissions integer Permissions to access the semaphore.
    private function init($maxLocks, $permissions)
    {
        $maxLocks = (int) $maxLocks;
        if ($maxLocks < 1) {
            $maxLocks = 1;
        }
        $this->key = abs(crc32(spl_object_hash($this)));
        $this->maxLocks = $maxLocks;
        $this->queue = msg_get_queue($this->key, $permissions);
        if (!$this->queue) {
            throw new SemaphoreException('Failed to create the semaphore.');
        }
        // Fill the semaphore with locks.
        while (--$maxLocks >= 0) {
            $this->release();
        }
    }