MCPcopy Create free account
hub / github.com/catboost/catboost / TestComputeCoroutineYield

Method TestComputeCoroutineYield

library/cpp/coroutine/engine/coroutine_ut.cpp:897–926  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

895}
896
897void TCoroTest::TestComputeCoroutineYield() {
898//if we have busy (e.g., on cpu) coroutine, when it yields, io must flow
899 TContExecutor exec(32000);
900 exec.SetFailOnError(true);
901
902 TPipe in, out;
903 TPipe::Pipe(in, out);
904 SetNonBlock(in.GetHandle());
905 size_t lastRead = 42;
906
907 auto compute = [&](TCont* cont) {
908 for (size_t i = 0; i < 10; ++i) {
909 write(out.GetHandle(), &i, sizeof i);
910 Sleep(TDuration::MilliSeconds(10));
911 cont->Yield();
912 UNIT_ASSERT(lastRead == i);
913 }
914 };
915
916 auto io = [&](TCont* cont) {
917 for (size_t i = 0; i < 10; ++i) {
918 NCoro::ReadI(cont, in.GetHandle(), &lastRead, sizeof lastRead);
919 }
920 };
921
922 exec.Create(compute, "compute");
923 exec.Create(io, "io");
924
925 exec.Execute();
926}
927
928void TCoroTest::TestPollEngines() {
929 bool defaultChecked = false;

Callers

nothing calls this directly

Calls 10

SetNonBlockFunction · 0.85
SleepFunction · 0.85
MilliSecondsFunction · 0.85
ReadIFunction · 0.85
SetFailOnErrorMethod · 0.80
YieldMethod · 0.80
writeFunction · 0.50
GetHandleMethod · 0.45
CreateMethod · 0.45
ExecuteMethod · 0.45

Tested by

no test coverage detected