mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-07 10:34:54 -06:00
reorganizing repo
git-svn-id: svn://ultimatepp.org/upp/trunk@9206 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
7d17505cfe
commit
e3e8d627f5
3840 changed files with 0 additions and 1161578 deletions
|
|
@ -1,56 +0,0 @@
|
|||
#include <Core/Core.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
static const int ITEMS = 10000;
|
||||
static const int PASSES = 5;
|
||||
static const int THREADS = 4;
|
||||
|
||||
volatile Atomic items[ITEMS];
|
||||
|
||||
static void ThreadProc(volatile Atomic *item, bool *finish)
|
||||
{
|
||||
AtomicInc(*item);
|
||||
*finish = true;
|
||||
}
|
||||
|
||||
static void TryMain()
|
||||
{
|
||||
for(int pass = 1; pass <= PASSES; pass++) {
|
||||
puts(NFormat("pass #%d", pass));
|
||||
fflush(stdout);
|
||||
for(int i = 0; i < ITEMS; i += THREADS) {
|
||||
if(i % (100 * THREADS) == 0) {
|
||||
puts(NFormat("i = %d", i));
|
||||
fflush(stdout);
|
||||
}
|
||||
bool thread_finished[THREADS];
|
||||
for(int t = 0; t < THREADS; t++) {
|
||||
if(i + t < ITEMS) {
|
||||
thread_finished[t] = false;
|
||||
Thread().Run(callback2(&ThreadProc, &items[i + t], &thread_finished[t]));
|
||||
}
|
||||
else
|
||||
thread_finished[t] = true;
|
||||
}
|
||||
for(;;) {
|
||||
bool done = true;
|
||||
for(int t = 0; t < THREADS; t++)
|
||||
if(!thread_finished[t]) {
|
||||
done = false;
|
||||
break;
|
||||
}
|
||||
if(done)
|
||||
break;
|
||||
Sleep(10);
|
||||
}
|
||||
}
|
||||
for(int i = 0; i < ITEMS; i++)
|
||||
if(items[i] != pass)
|
||||
RLOG("pass #" << pass << ": error at [" << i << "] = " << (int)items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
CONSOLE_APP_MAIN {
|
||||
TryMain();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue