mirror of
https://github.com/danog/parallel.git
synced 2024-12-13 17:47:32 +01:00
c7294da60d
TaskError is thrown if the exception thrown in the worker was an instance of Error.
30 lines
729 B
PHP
30 lines
729 B
PHP
<?php
|
|
|
|
namespace Amp\Parallel\Test\Sync;
|
|
|
|
use Amp\Parallel\Sync\Lock;
|
|
use Amp\PHPUnit\TestCase;
|
|
|
|
class LockTest extends TestCase {
|
|
public function testIsReleased() {
|
|
$lock = new Lock($this->createCallback(1));
|
|
$this->assertFalse($lock->isReleased());
|
|
$lock->release();
|
|
$this->assertTrue($lock->isReleased());
|
|
}
|
|
|
|
public function testIsReleasedOnDestruct() {
|
|
$lock = new Lock($this->createCallback(1));
|
|
unset($lock);
|
|
}
|
|
|
|
/**
|
|
* @expectedException \Amp\Parallel\Sync\LockAlreadyReleasedError
|
|
*/
|
|
public function testThrowsOnMultiRelease() {
|
|
$lock = new Lock($this->createCallback(1));
|
|
$lock->release();
|
|
$lock->release();
|
|
}
|
|
}
|