Inheritance: implements Jenner\SimpleFork\Lock\LockInterface
コード例 #1
0
 public function testCommunication()
 {
     if (version_compare(PHP_VERSION, '5.6.0') < 0) {
         $this->markTestSkipped("php version is too low");
     }
     $process = new \Jenner\SimpleFork\Process(function () {
         $lock = \Jenner\SimpleFork\Lock\Semaphore::create('test');
         $lock->acquire(false);
         sleep(5);
         $lock->release();
     });
     $process->start();
     sleep(3);
     $lock = \Jenner\SimpleFork\Lock\Semaphore::create("test");
     $this->assertFalse($lock->acquire(false));
     $process->wait();
     $this->assertTrue($lock->acquire(false));
     $this->assertTrue($lock->release());
 }
コード例 #2
0
<?php

/**
 * Created by PhpStorm.
 * User: Jenner
 * Date: 2015/10/26
 * Time: 15:49
 */
require dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
$process = new \Jenner\SimpleFork\Process(function () {
    $lock = \Jenner\SimpleFork\Lock\Semaphore::create('test');
    var_dump($lock->acquire());
    sleep(5);
    var_dump($lock->release());
});
$process->start();
sleep(3);
$lock = \Jenner\SimpleFork\Lock\Semaphore::create("test");
$this->assertFalse($lock->acquire());
$process->wait();
$this->assertTrue($lock->acquire());
$this->assertTrue($lock->release());
コード例 #3
0
 public function release($server, $loop)
 {
     return $this->sem->release();
 }
コード例 #4
0
 public function __construct()
 {
     $this->sem = \Jenner\SimpleFork\Lock\Semaphore::create("test");
 }