Swoole\Lock->unlock

Declaration

<?php
Swoole\Lock->unlock()

Parameters

Return

Description

Relase the lock and allow the other process to acquire the lock.

Example

<?php

$lock = new Swoole\Lock(SWOOLE_MUTEX);
echo "[Master] Create lock\n";
$lock->lock();
if (pcntl_fork() > 0)
{
    sleep(1);
    $lock->unlock();
} 
else
{
    echo "[Child] Wait Lock\n";
    $lock->lock();
    echo "[Child] Get Lock\n";
    $lock->unlock();
    exit("[Child] exit\n");
}
echo "[Master]release lock\n";
unset($lock);
sleep(1);
echo "[Master]exit\n";