mirror of
https://github.com/amphp/parallel.git
synced 2025-07-22 22:11:20 +02:00
31 lines
639 B
PHP
31 lines
639 B
PHP
<?php
|
|
|
|
namespace Amp\Parallel\Test\Threading;
|
|
|
|
use Amp\Loop;
|
|
use Amp\Parallel\Threading\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();
|
|
});
|
|
|
|
}
|
|
}
|