@@ -38,38 +38,27 @@ TEST(Work, RunTask) {
3838
3939TEST (Work, Cancellation) {
4040 auto loop = uvw::Loop::getDefault ();
41- auto handle = loop->resource <uvw::CheckHandle >();
41+ auto handle = loop->resource <uvw::TimerHandle >();
4242
4343 bool checkErrorEvent = false ;
44- bool checkWorkEvent = false ;
45- bool checkTask = false ;
4644
47- handle->on <uvw::CheckEvent >([](const auto &, auto &hndl) {
45+ handle->on <uvw::TimerEvent >([](const auto &, auto &hndl) {
4846 hndl.stop ();
4947 hndl.close ();
5048 });
5149
52- auto req = loop->resource <uvw::WorkReq>([&checkTask]() {
53- ASSERT_FALSE (checkTask);
54- checkTask = true ;
55- });
50+ for (auto i = 0 ; i < 5 /* default uv thread pool size + 1 */ ; ++i) {
51+ auto req = loop->resource <uvw::WorkReq>([]() {});
5652
57- req->on <uvw::ErrorEvent>([&checkErrorEvent](const auto &, auto &) {
58- ASSERT_FALSE (checkErrorEvent);
59- checkErrorEvent = true ;
60- });
53+ req->on <uvw::WorkEvent>([](const auto &, auto &) {});
54+ req->on <uvw::ErrorEvent>([&checkErrorEvent](const auto &, auto &) { checkErrorEvent = true ; });
6155
62- req->on <uvw::WorkEvent>([&checkWorkEvent](const auto &, auto &) {
63- ASSERT_FALSE (checkWorkEvent);
64- checkWorkEvent = true ;
65- });
56+ req->queue ();
57+ req->cancel ();
58+ }
6659
67- handle->start ();
68- req->queue ();
69- req->cancel ();
60+ handle->start (uvw::TimerHandle::Time{500 }, uvw::TimerHandle::Time{500 });
7061 loop->run ();
7162
7263 ASSERT_TRUE (checkErrorEvent);
73- ASSERT_FALSE (checkWorkEvent);
74- ASSERT_FALSE (checkTask);
7564}
0 commit comments