mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-29 06:12:18 -06:00
Reorganizing REPO
git-svn-id: svn://ultimatepp.org/upp/trunk@11631 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
036f42e17f
commit
f6fc5c2afb
83 changed files with 10859 additions and 10821 deletions
37
reference/CoWorkLoop/CoWorkLoop.cpp
Normal file
37
reference/CoWorkLoop/CoWorkLoop.cpp
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue