Ejemplo n.º 1
0
 public function testLock()
 {
     $semaphore = new Semaphore();
     $key = uniqid();
     $this->assertTrue($semaphore->lock($key));
     $this->assertFalse($semaphore->lock($key));
     $this->assertTrue($semaphore->unlock($key));
     $this->assertFalse($semaphore->unlock($key));
 }
Ejemplo n.º 2
0
<?php

require 'vendor/autoload.php';
use Semaphore\Semaphore;
$s = new Semaphore();
var_dump($s->lock('1'));
var_dump($s->lock('1'));
var_dump($s->locked('1'));
var_dump($s->unlock('1'));
var_dump($s->unlock('1'));