ultimatepp/autotest/AsyncWork2/AsyncWork2.cpp
cxl a9c85041ef .autotest
git-svn-id: svn://ultimatepp.org/upp/trunk@11369 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2017-10-11 17:28:42 +00:00

33 lines
453 B
C++

#include <Core/Core.h>
using namespace Upp;
Atomic h;
void Wait(int c)
{
while(c--)
h++;
}
CONSOLE_APP_MAIN
{
StdLogSetup(LOG_COUT|LOG_FILE);
for(int i = 0; i < 100000; i++) {
if(i % 1000 == 0)
LOG(i);
bool b = false;
auto x = Async([] { Wait(Random(3000)); throw "error"; });
try {
Wait(Random(3000));
x.Get();
}
catch(...) {
b = true;
}
ASSERT(b);
}
LOG("============ OK");
}