aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/coroutine/engine/coroutine_ut.cpp
diff options
context:
space:
mode:
authorprout <prout@yandex-team.ru>2022-02-10 16:49:42 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:42 +0300
commit7b7fa28b9099b7adca890459a699c6ba5eeff4ca (patch)
treecffe238e08f715008f864d223dd0db8fc1f92f9f /library/cpp/coroutine/engine/coroutine_ut.cpp
parent0fd1998e1b2369f50fb694556f817d3c7fef10c8 (diff)
downloadydb-7b7fa28b9099b7adca890459a699c6ba5eeff4ca.tar.gz
Restoring authorship annotation for <prout@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/coroutine/engine/coroutine_ut.cpp')
-rw-r--r--library/cpp/coroutine/engine/coroutine_ut.cpp102
1 files changed, 51 insertions, 51 deletions
diff --git a/library/cpp/coroutine/engine/coroutine_ut.cpp b/library/cpp/coroutine/engine/coroutine_ut.cpp
index 8b372496a2..82afafcfa0 100644
--- a/library/cpp/coroutine/engine/coroutine_ut.cpp
+++ b/library/cpp/coroutine/engine/coroutine_ut.cpp
@@ -326,99 +326,99 @@ void TCoroTest::TestCondVar() {
}
namespace NCoroTestJoin {
- struct TSleepCont {
- const TInstant Deadline;
- int Result;
-
- inline void operator()(TCont* c) {
- Result = c->SleepD(Deadline);
- }
- };
-
- struct TReadCont {
- const TInstant Deadline;
- const SOCKET Sock;
- int Result;
-
- inline void operator()(TCont* c) {
- char buf = 0;
+ struct TSleepCont {
+ const TInstant Deadline;
+ int Result;
+
+ inline void operator()(TCont* c) {
+ Result = c->SleepD(Deadline);
+ }
+ };
+
+ struct TReadCont {
+ const TInstant Deadline;
+ const SOCKET Sock;
+ int Result;
+
+ inline void operator()(TCont* c) {
+ char buf = 0;
Result = NCoro::ReadD(c, Sock, &buf, sizeof(buf), Deadline).Status();
- }
- };
-
- struct TJoinCont {
- const TInstant Deadline;
- TCont* const Cont;
- bool Result;
-
- inline void operator()(TCont* c) {
- Result = c->Join(Cont, Deadline);
- }
- };
-
+ }
+ };
+
+ struct TJoinCont {
+ const TInstant Deadline;
+ TCont* const Cont;
+ bool Result;
+
+ inline void operator()(TCont* c) {
+ Result = c->Join(Cont, Deadline);
+ }
+ };
+
void DoTestJoin(EContPoller pollerType) {
auto poller = IPollerFace::Construct(pollerType);
-
+
if (!poller) {
return;
}
-
+
TContExecutor e(32000, std::move(poller));
-
+
TPipe in, out;
TPipe::Pipe(in, out);
SetNonBlock(in.GetHandle());
-
+
{
TSleepCont sc = {TInstant::Max(), 0};
TJoinCont jc = {TDuration::MilliSeconds(100).ToDeadLine(), e.Create(sc, "sc"), true};
-
+
e.Execute(jc);
-
+
UNIT_ASSERT_EQUAL(sc.Result, ECANCELED);
UNIT_ASSERT_EQUAL(jc.Result, false);
}
-
+
{
TSleepCont sc = {TDuration::MilliSeconds(100).ToDeadLine(), 0};
TJoinCont jc = {TDuration::MilliSeconds(200).ToDeadLine(), e.Create(sc, "sc"), false};
-
+
e.Execute(jc);
-
+
UNIT_ASSERT_EQUAL(sc.Result, ETIMEDOUT);
UNIT_ASSERT_EQUAL(jc.Result, true);
}
-
+
{
TSleepCont sc = {TDuration::MilliSeconds(200).ToDeadLine(), 0};
TJoinCont jc = {TDuration::MilliSeconds(100).ToDeadLine(), e.Create(sc, "sc"), true};
-
+
e.Execute(jc);
-
+
UNIT_ASSERT_EQUAL(sc.Result, ECANCELED);
UNIT_ASSERT_EQUAL(jc.Result, false);
}
-
+
{
TReadCont rc = {TInstant::Max(), in.GetHandle(), 0};
TJoinCont jc = {TDuration::MilliSeconds(100).ToDeadLine(), e.Create(rc, "rc"), true};
-
+
e.Execute(jc);
-
+
UNIT_ASSERT_EQUAL(rc.Result, ECANCELED);
UNIT_ASSERT_EQUAL(jc.Result, false);
}
-
+
{
TReadCont rc = {TDuration::MilliSeconds(100).ToDeadLine(), in.GetHandle(), 0};
TJoinCont jc = {TDuration::MilliSeconds(200).ToDeadLine(), e.Create(rc, "rc"), false};
-
+
e.Execute(jc);
-
+
UNIT_ASSERT_EQUAL(rc.Result, ETIMEDOUT);
UNIT_ASSERT_EQUAL(jc.Result, true);
}
-
+
{
TReadCont rc = {TDuration::MilliSeconds(200).ToDeadLine(), in.GetHandle(), 0};
TJoinCont jc = {TDuration::MilliSeconds(100).ToDeadLine(), e.Create(rc, "rc"), true};
@@ -428,9 +428,9 @@ namespace NCoroTestJoin {
UNIT_ASSERT_EQUAL(rc.Result, ECANCELED);
UNIT_ASSERT_EQUAL(jc.Result, false);
}
- }
-}
-
+ }
+}
+
void TCoroTest::TestJoinDefault() {
NCoroTestJoin::DoTestJoin(EContPoller::Default);
}