1
0
mirror of https://github.com/danog/parallel.git synced 2024-11-27 04:44:56 +01:00

A mutex based on the sync extension

This commit is contained in:
coderstephen 2015-08-01 21:18:14 -05:00
parent cf788a9377
commit 9b63e7fe7d

39
src/Sync/ExtSyncMutex.php Normal file
View File

@ -0,0 +1,39 @@
<?php
namespace Icicle\Concurrent\Sync;
use Icicle\Concurrent\Exception\MutexException;
/**
* A wrapper for a mutex based on the "sync" extension.
*/
class ExtSyncMutex implements MutexInterface
{
/**
* @var \SyncMutex A mutex instance.
*/
private $mutex;
/**
* Creates a new mutex object.
*/
public function __construct()
{
$this->mutex = new \SyncMutex();
}
/**
* {@inheritdoc}
*/
public function lock()
{
$this->mutex->lock(-1);
}
/**
* {@inheritdoc}
*/
public function unlock()
{
$this->mutex->unlock(false);
}
}