1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-03 18:17:52 +01:00
parallel/test/Threading/ThreadTest.php

28 lines
601 B
PHP
Raw Normal View History

2016-08-22 06:40:48 +02:00
<?php declare(strict_types = 1);
2015-08-28 23:58:15 +02:00
2016-08-23 23:47:40 +02:00
namespace Amp\Parallel\Test\Threading;
2016-08-18 18:04:48 +02:00
2016-08-23 23:47:40 +02:00
use Amp\Parallel\Threading\Thread;
use Amp\Parallel\Test\AbstractContextTest;
2015-08-28 23:58:15 +02:00
/**
* @group threading
* @requires extension pthreads
*/
2016-08-19 00:36:58 +02:00
class ThreadTest extends AbstractContextTest {
public function createContext(callable $function) {
return new Thread($function);
}
2016-08-19 00:36:58 +02:00
public function testSpawnStartsThread() {
\Amp\execute(function () {
$thread = Thread::spawn(function () {
usleep(100);
});
2016-08-19 00:36:58 +02:00
return yield $thread->join();
});
}
2015-08-28 23:58:15 +02:00
}