ultimatepp/autotest/CoPipe2/CoPipe2.cpp
cxl 5edae0e110 .reorganizing
git-svn-id: svn://ultimatepp.org/upp/trunk@9759 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2016-05-01 20:21:16 +00:00

32 lines
588 B
C++

#include <Core/Core.h>
using namespace Upp;
Vector<String> result;
void Process(CoWork& co, String h, int n)
{
int x = atoi(h);
x++;
if(n < 100)
co.Pipe(n + 1, [=, &co] { Process(co, AsString(atoi(h) + 1), n + 1); });
else
result.Add(h);
}
CONSOLE_APP_MAIN
{
StdLogSetup(LOG_COUT|LOG_FILE);
CoWork co;
for(int i = 0; i < 10000; i++)
co.Pipe(0, [=, &co] { Process(co, AsString(i), 0); });
co.Finish();
for(int i = 0; i < 10000; i++)
ASSERT(result[i] == AsString(i + 100));
Thread::ShutdownThreads();
LOG("============== OK");
}