mirror of
https://github.com/danog/parallel.git
synced 2024-12-02 17:52:14 +01:00
30 lines
634 B
PHP
30 lines
634 B
PHP
<?php
|
|
|
|
namespace Amp\Parallel\Test\Context;
|
|
|
|
use Amp\Loop;
|
|
use Amp\Parallel\Context\Thread;
|
|
use Amp\Parallel\Test\AbstractContextTest;
|
|
|
|
/**
|
|
* @group threading
|
|
* @requires extension pthreads
|
|
*/
|
|
class ThreadTest extends AbstractContextTest {
|
|
public function createContext(callable $function) {
|
|
return new Thread($function);
|
|
}
|
|
|
|
public function testSpawnStartsThread() {
|
|
Loop::run(function () {
|
|
$thread = Thread::spawn(function () {
|
|
usleep(100);
|
|
});
|
|
|
|
$this->assertTrue($thread->isRunning());
|
|
|
|
return yield $thread->join();
|
|
});
|
|
}
|
|
}
|