malkusch\lock\mutex\MutexConcurrencyTest::testSerialisation PHP Метод

testSerialisation() публичный Метод

Tests that two processes run sequentially.
public testSerialisation ( callable $mutexFactory )
$mutexFactory callable The Mutex factory.
    public function testSerialisation(callable $mutexFactory)
    {
        $timestamp = microtime(true);
        $this->fork(2, function () use($mutexFactory) {
            $mutex = call_user_func($mutexFactory);
            $mutex->synchronized(function () {
                usleep(500000);
            });
        });
        $delta = microtime(true) - $timestamp;
        $this->assertGreaterThan(1, $delta);
    }