| 361 | }; |
| 362 | |
| 363 | void DoTestJoin(EContPoller pollerType) { |
| 364 | auto poller = IPollerFace::Construct(pollerType); |
| 365 | |
| 366 | if (!poller) { |
| 367 | return; |
| 368 | } |
| 369 | |
| 370 | TContExecutor e(32000, std::move(poller)); |
| 371 | |
| 372 | TPipe in, out; |
| 373 | TPipe::Pipe(in, out); |
| 374 | SetNonBlock(in.GetHandle()); |
| 375 | |
| 376 | { |
| 377 | TSleepCont sc = {TInstant::Max(), 0}; |
| 378 | TJoinCont jc = {TDuration::MilliSeconds(100).ToDeadLine(), e.Create(sc, "sc"), true}; |
| 379 | |
| 380 | e.Execute(jc); |
| 381 | |
| 382 | UNIT_ASSERT_EQUAL(sc.Result, ECANCELED); |
| 383 | UNIT_ASSERT_EQUAL(jc.Result, false); |
| 384 | } |
| 385 | |
| 386 | { |
| 387 | TSleepCont sc = {TDuration::MilliSeconds(100).ToDeadLine(), 0}; |
| 388 | TJoinCont jc = {TDuration::MilliSeconds(200).ToDeadLine(), e.Create(sc, "sc"), false}; |
| 389 | |
| 390 | e.Execute(jc); |
| 391 | |
| 392 | UNIT_ASSERT_EQUAL(sc.Result, ETIMEDOUT); |
| 393 | UNIT_ASSERT_EQUAL(jc.Result, true); |
| 394 | } |
| 395 | |
| 396 | { |
| 397 | TSleepCont sc = {TDuration::MilliSeconds(200).ToDeadLine(), 0}; |
| 398 | TJoinCont jc = {TDuration::MilliSeconds(100).ToDeadLine(), e.Create(sc, "sc"), true}; |
| 399 | |
| 400 | e.Execute(jc); |
| 401 | |
| 402 | UNIT_ASSERT_EQUAL(sc.Result, ECANCELED); |
| 403 | UNIT_ASSERT_EQUAL(jc.Result, false); |
| 404 | } |
| 405 | |
| 406 | { |
| 407 | TReadCont rc = {TInstant::Max(), in.GetHandle(), 0}; |
| 408 | TJoinCont jc = {TDuration::MilliSeconds(100).ToDeadLine(), e.Create(rc, "rc"), true}; |
| 409 | |
| 410 | e.Execute(jc); |
| 411 | |
| 412 | UNIT_ASSERT_EQUAL(rc.Result, ECANCELED); |
| 413 | UNIT_ASSERT_EQUAL(jc.Result, false); |
| 414 | } |
| 415 | |
| 416 | { |
| 417 | TReadCont rc = {TDuration::MilliSeconds(100).ToDeadLine(), in.GetHandle(), 0}; |
| 418 | TJoinCont jc = {TDuration::MilliSeconds(200).ToDeadLine(), e.Create(rc, "rc"), false}; |
| 419 | |
| 420 | e.Execute(jc); |