Skip to content

Commit 4279a10

Browse files
committed
fix, add test
1 parent 67e8610 commit 4279a10

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

swoole_coroutine.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ ZEND_END_ARG_INFO()
130130
bool PHPCoroutine::active = false;
131131
uint64_t PHPCoroutine::max_num = SW_DEFAULT_MAX_CORO_NUM;
132132
php_coro_task PHPCoroutine::main_task = {0};
133-
133+
pthread_t PHPCoroutine::schedule_thread_id;
134134
bool PHPCoroutine::schedule_thread_running = false;
135135

136136
static zend_bool* zend_vm_interrupt = nullptr;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
swoole_coroutine_scheduler: hook_flags
3+
--SKIPIF--
4+
<?php require __DIR__ . '/../include/skipif.inc'; ?>
5+
--FILE--
6+
<?php
7+
require __DIR__ . '/../include/bootstrap.php';
8+
9+
$sch = scheduler();
10+
11+
$sch->set(['hook_flags' => SWOOLE_HOOK_ALL,]);
12+
13+
$sch->add(function ($t, $n) {
14+
sleep($t);
15+
echo "$n\n";
16+
}, 0.2, 'A');
17+
18+
$sch->add(function ($t, $n) {
19+
sleep($t);
20+
echo "$n\n";
21+
}, 0.1, 'B');
22+
23+
$sch->add(function () {
24+
var_dump(Co::getCid());
25+
});
26+
27+
$sch->start();
28+
29+
?>
30+
--EXPECTF--
31+
int(%d)
32+
B
33+
A

0 commit comments

Comments
 (0)