Skip to content

Commit

Permalink
add some TaskTest diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-f committed Oct 24, 2023
1 parent b4b5f02 commit 9fcbff1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Foundation/include/Poco/Event_POSIX.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class Foundation_API EventImpl
void resetImpl();

private:
bool _auto;
bool _state;
std::atomic<bool> _auto;
std::atomic<bool> _state;
pthread_mutex_t _mutex;
pthread_cond_t _cond;
};
Expand Down
43 changes: 33 additions & 10 deletions Foundation/testsuite/src/TaskTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "Poco/Thread.h"
#include "Poco/Event.h"
#include "Poco/AutoPtr.h"
#include <iostream>


using Poco::Task;
Expand All @@ -34,20 +35,42 @@ namespace

void runTask()
{
_event.wait();
if (sleep(10))
return;
setProgress(0.5);
_event.wait();
if (isCancelled())
return;
setProgress(1.0);
_event.wait();
try
{
_event.wait();
if (sleep(10))
return;
setProgress(0.5);
_event.wait();
if (isCancelled())
return;
setProgress(1.0);
_event.wait();
}
catch(const Poco::Exception& e)
{
std::cerr << "TestTask::run(): " << e.displayText() << '\n';
}
catch(const std::exception& e)
{
std::cerr << "TestTask::run(): " << e.what() << '\n';
}
catch(...)
{
std::cerr << "TestTask::run(): unknown exception." << '\n';
}
}

void cont()
{
_event.set();
try
{
_event.set();
}
catch(const Poco::SystemException& e)
{
std::cerr << "TestTask::cont(): " << e.displayText() << '\n';
}
}

private:
Expand Down

0 comments on commit 9fcbff1

Please sign in to comment.