ultimatepp/reference/CoWorkLoop/CoWorkLoop.cpp
cxl afb3d587da Reorganizing REPO
git-svn-id: svn://ultimatepp.org/upp/trunk@11631 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2017-12-26 10:28:32 +00:00

37 lines
599 B
C++

#include <Core/Core.h>
using namespace Upp;
force_inline double Sum(const String& s)
{
CParser p(s);
double sum = 0;
while(!p.IsEof())
sum += p.ReadDouble();
return sum;
}
CONSOLE_APP_MAIN
{
SeedRandom(0);
Vector<String> data;
for(int i = 0; i < 10000000; i++) {
int n = Random(7);
data.Add();
for(int j = 0; j < n; j++)
data.Top() << Random() << ' ';
}
double sum = 0;
CoWork co;
co * [&] {
double m = 0;
int i;
while((i = co.Next()) < data.GetCount())
m += Sum(data[i]);
CoWork::FinLock();
sum += m;
};
RDUMP(sum);
}