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:
parent
cf788a9377
commit
9b63e7fe7d
39
src/Sync/ExtSyncMutex.php
Normal file
39
src/Sync/ExtSyncMutex.php
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user