Semaphores fully implemented
This commit is contained in:
27
tests/Sem/SemaphoreTest.php
Normal file
27
tests/Sem/SemaphoreTest.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace NoccyLabs\Ipc\Sem;
|
||||
|
||||
use NoccyLabs\Ipc\Key\FileKey;
|
||||
|
||||
|
||||
|
||||
class SemaphoreTest extends \PhpUnit\Framework\TestCase
|
||||
{
|
||||
|
||||
public function testCreatingAndAquiringSemaphore()
|
||||
{
|
||||
$key = new FileKey(__FILE__);
|
||||
$sem = new Semaphore($key, 2);
|
||||
|
||||
$this->assertTrue($sem->acquire());
|
||||
$this->assertTrue($sem->acquire());
|
||||
$this->assertFalse($sem->acquire());
|
||||
$this->assertTrue($sem->release());
|
||||
$this->assertTrue($sem->acquire());
|
||||
$this->assertFalse($sem->acquire());
|
||||
$this->assertTrue($sem->release());
|
||||
$this->assertTrue($sem->release());
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user