mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-26 10:32:56 +01:00
Updated Event c'tor to accept an enum.
This commit is contained in:
@@ -43,7 +43,7 @@ public:
|
|||||||
ActiveResultHolder():
|
ActiveResultHolder():
|
||||||
_pData(0),
|
_pData(0),
|
||||||
_pExc(0),
|
_pExc(0),
|
||||||
_event(false)
|
_event(Event::EVENT_MANUALRESET)
|
||||||
/// Creates an ActiveResultHolder.
|
/// Creates an ActiveResultHolder.
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,7 @@ class ActiveResultHolder<void>: public RefCountedObject
|
|||||||
public:
|
public:
|
||||||
ActiveResultHolder():
|
ActiveResultHolder():
|
||||||
_pExc(0),
|
_pExc(0),
|
||||||
_event(false)
|
_event(Event::EVENT_MANUALRESET)
|
||||||
/// Creates an ActiveResultHolder.
|
/// Creates an ActiveResultHolder.
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public:
|
|||||||
_runnable(*pOwner, method),
|
_runnable(*pOwner, method),
|
||||||
_stopped(true),
|
_stopped(true),
|
||||||
_running(false),
|
_running(false),
|
||||||
_done(false)
|
_done(Event::EVENT_MANUALRESET)
|
||||||
/// Creates the activity. Call start() to
|
/// Creates the activity. Call start() to
|
||||||
/// start it.
|
/// start it.
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,7 +46,19 @@ class Foundation_API Event: private EventImpl
|
|||||||
/// for an event to become signalled.
|
/// for an event to become signalled.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Event(bool autoReset = true);
|
enum EventType
|
||||||
|
{
|
||||||
|
EVENT_MANUALRESET = EVENT_MANUALRESET_IMPL, /// Manual reset event
|
||||||
|
EVENT_AUTORESET = EVENT_AUTORESET_IMPL, /// Auto-reset event
|
||||||
|
};
|
||||||
|
|
||||||
|
Event(EventType type = EVENT_AUTORESET);
|
||||||
|
/// Creates the event. If type is EVENT_AUTORESET,
|
||||||
|
/// the event is automatically reset after
|
||||||
|
/// a wait() successfully returns.
|
||||||
|
|
||||||
|
Event(bool autoReset);
|
||||||
|
//@ deprecated
|
||||||
/// Creates the event. If autoReset is true,
|
/// Creates the event. If autoReset is true,
|
||||||
/// the event is automatically reset after
|
/// the event is automatically reset after
|
||||||
/// a wait() successfully returns.
|
/// a wait() successfully returns.
|
||||||
|
|||||||
@@ -31,8 +31,15 @@ namespace Poco {
|
|||||||
|
|
||||||
class Foundation_API EventImpl
|
class Foundation_API EventImpl
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
enum EventTypeImpl
|
||||||
|
{
|
||||||
|
EVENT_MANUALRESET_IMPL,
|
||||||
|
EVENT_AUTORESET_IMPL,
|
||||||
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
EventImpl(bool autoReset);
|
EventImpl(EventTypeImpl type);
|
||||||
~EventImpl();
|
~EventImpl();
|
||||||
void setImpl();
|
void setImpl();
|
||||||
void waitImpl();
|
void waitImpl();
|
||||||
|
|||||||
@@ -30,8 +30,15 @@ namespace Poco {
|
|||||||
|
|
||||||
class Foundation_API EventImpl
|
class Foundation_API EventImpl
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
enum EventTypeImpl
|
||||||
|
{
|
||||||
|
EVENT_MANUALRESET_IMPL,
|
||||||
|
EVENT_AUTORESET_IMPL,
|
||||||
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
EventImpl(bool autoReset);
|
EventImpl(EventTypeImpl type);
|
||||||
~EventImpl();
|
~EventImpl();
|
||||||
void setImpl();
|
void setImpl();
|
||||||
void waitImpl();
|
void waitImpl();
|
||||||
|
|||||||
@@ -30,8 +30,15 @@ namespace Poco {
|
|||||||
|
|
||||||
class Foundation_API EventImpl
|
class Foundation_API EventImpl
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
enum EventTypeImpl
|
||||||
|
{
|
||||||
|
EVENT_MANUALRESET_IMPL,
|
||||||
|
EVENT_AUTORESET_IMPL,
|
||||||
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
EventImpl(bool autoReset);
|
EventImpl(EventTypeImpl type);
|
||||||
~EventImpl();
|
~EventImpl();
|
||||||
void setImpl();
|
void setImpl();
|
||||||
void waitImpl();
|
void waitImpl();
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ private:
|
|||||||
thread(0),
|
thread(0),
|
||||||
prio(PRIO_NORMAL_IMPL),
|
prio(PRIO_NORMAL_IMPL),
|
||||||
policy(SCHED_OTHER),
|
policy(SCHED_OTHER),
|
||||||
done(false),
|
done(Event::EVENT_MANUALRESET),
|
||||||
stackSize(POCO_THREAD_STACK_SIZE),
|
stackSize(POCO_THREAD_STACK_SIZE),
|
||||||
started(false),
|
started(false),
|
||||||
joined(false)
|
joined(false)
|
||||||
|
|||||||
@@ -50,12 +50,12 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
{
|
{
|
||||||
Poco::Mutex mtx(Poco::Mutex::MUTEX_RECURSIVE);
|
Poco::Mutex mtx(Poco::Mutex::MUTEX_RECURSIVE);
|
||||||
Benchmark(mtx, "Mutex(true)");
|
Benchmark(mtx, "Mutex(MUTEX_RECURSIVE)");
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Poco::Mutex mtx(Poco::Mutex::MUTEX_NONRECURSIVE);
|
Poco::Mutex mtx(Poco::Mutex::MUTEX_NONRECURSIVE);
|
||||||
Benchmark(mtx, "Mutex(false)");
|
Benchmark(mtx, "Mutex(MUTEX_NONRECURSIVE)");
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,7 +29,12 @@
|
|||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
Event::Event(bool autoReset): EventImpl(autoReset)
|
Event::Event(EventType type): EventImpl((EventTypeImpl) type)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Event::Event(bool autoReset): EventImpl(autoReset ? EVENT_AUTORESET_IMPL : EVENT_MANUALRESET_IMPL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
EventImpl::EventImpl(bool autoReset): _auto(autoReset), _state(false)
|
EventImpl::EventImpl(EventTypeImpl type): _auto(type == EVENT_AUTORESET_IMPL), _state(false)
|
||||||
{
|
{
|
||||||
#if defined(POCO_VXWORKS)
|
#if defined(POCO_VXWORKS)
|
||||||
// This workaround is for VxWorks 5.x where
|
// This workaround is for VxWorks 5.x where
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
EventImpl::EventImpl(bool autoReset): _auto(autoReset), _state(false)
|
EventImpl::EventImpl(EventTypeImpl type): _auto(type == EVENT_AUTORESET_IMPL), _state(false)
|
||||||
{
|
{
|
||||||
_sem = semCCreate(SEM_Q_PRIORITY, 0);
|
_sem = semCCreate(SEM_Q_PRIORITY, 0);
|
||||||
if (_sem == 0)
|
if (_sem == 0)
|
||||||
|
|||||||
@@ -20,9 +20,9 @@
|
|||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
EventImpl::EventImpl(bool autoReset)
|
EventImpl::EventImpl(EventTypeImpl type)
|
||||||
{
|
{
|
||||||
_event = CreateEventW(NULL, autoReset ? FALSE : TRUE, FALSE, NULL);
|
_event = CreateEventW(NULL, type == EVENT_AUTORESET_IMPL ? FALSE : TRUE, FALSE, NULL);
|
||||||
if (!_event)
|
if (!_event)
|
||||||
throw SystemException("cannot create event");
|
throw SystemException("cannot create event");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ Task::Task(const std::string& name):
|
|||||||
_pOwner(0),
|
_pOwner(0),
|
||||||
_progress(0),
|
_progress(0),
|
||||||
_state(TASK_IDLE),
|
_state(TASK_IDLE),
|
||||||
_cancelEvent(false)
|
_cancelEvent(Event::EVENT_MANUALRESET)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ Thread::Thread():
|
|||||||
_id(uniqueId()),
|
_id(uniqueId()),
|
||||||
_name(makeName()),
|
_name(makeName()),
|
||||||
_pTLS(0),
|
_pTLS(0),
|
||||||
_event(true)
|
_event()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ Thread::Thread(const std::string& name):
|
|||||||
_id(uniqueId()),
|
_id(uniqueId()),
|
||||||
_name(name),
|
_name(name),
|
||||||
_pTLS(0),
|
_pTLS(0),
|
||||||
_event(true)
|
_event()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,10 @@ PooledThread::PooledThread(const std::string& name, int stackSize):
|
|||||||
_pTarget(0),
|
_pTarget(0),
|
||||||
_name(name),
|
_name(name),
|
||||||
_thread(name),
|
_thread(name),
|
||||||
_targetCompleted(false)
|
_targetReady(),
|
||||||
|
_targetCompleted(Event::EVENT_MANUALRESET),
|
||||||
|
_started(),
|
||||||
|
_mutex()
|
||||||
{
|
{
|
||||||
poco_assert_dbg (stackSize >= 0);
|
poco_assert_dbg (stackSize >= 0);
|
||||||
_thread.setStackSize(stackSize);
|
_thread.setStackSize(stackSize);
|
||||||
|
|||||||
@@ -19,12 +19,13 @@
|
|||||||
#include "Poco/Thread.h"
|
#include "Poco/Thread.h"
|
||||||
|
|
||||||
|
|
||||||
|
using Poco::Event;
|
||||||
using Poco::ThreadPool;
|
using Poco::ThreadPool;
|
||||||
using Poco::RunnableAdapter;
|
using Poco::RunnableAdapter;
|
||||||
using Poco::Thread;
|
using Poco::Thread;
|
||||||
|
|
||||||
|
|
||||||
ThreadPoolTest::ThreadPoolTest(const std::string& name): CppUnit::TestCase(name), _event(false)
|
ThreadPoolTest::ThreadPoolTest(const std::string& name): CppUnit::TestCase(name), _event(Event::EVENT_MANUALRESET)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user