mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-01 17:25:03 +02:00
* include/Poco/Tuple.h
- Named the inner enumerations to fix SF issue#1834127 * include/Poco/RunnableAdapter.h - Added missing ``return *this'' to RunnableAdapter::operator= * src/TaskManager.cpp - Added try-catch block in TaskManager::start to ensure that _taskList is properly maintained. Fix for SF issue#1829700 * testsuite/src/TaskManagerTest.cpp * testsuite/src/TaskManagerTest.h - Added test cases for SF issue@1829700
This commit is contained in:
parent
6068e26cdd
commit
fbb1c1fd44
@ -75,6 +75,7 @@ public:
|
||||
{
|
||||
_pObject = ra._pObject;
|
||||
_method = ra._method;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void run()
|
||||
|
@ -78,7 +78,7 @@ struct Tuple
|
||||
{
|
||||
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>::HeadType Type;
|
||||
|
||||
enum
|
||||
enum TupleLengthType
|
||||
{
|
||||
length = Type::length
|
||||
};
|
||||
@ -191,7 +191,7 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,N
|
||||
{
|
||||
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>::HeadType Type;
|
||||
|
||||
enum
|
||||
enum TupleLengthType
|
||||
{
|
||||
length = Type::length
|
||||
};
|
||||
@ -301,7 +301,7 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,NullT
|
||||
{
|
||||
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>::HeadType Type;
|
||||
|
||||
enum
|
||||
enum TupleLengthType
|
||||
{
|
||||
length = Type::length
|
||||
};
|
||||
@ -408,7 +408,7 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,NullTypeL
|
||||
{
|
||||
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>::HeadType Type;
|
||||
|
||||
enum
|
||||
enum TupleLengthType
|
||||
{
|
||||
length = Type::length
|
||||
};
|
||||
@ -512,7 +512,7 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,NullTypeList>
|
||||
{
|
||||
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>::HeadType Type;
|
||||
|
||||
enum
|
||||
enum TupleLengthType
|
||||
{
|
||||
length = Type::length
|
||||
};
|
||||
@ -613,7 +613,7 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,NullTypeList>
|
||||
{
|
||||
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>::HeadType Type;
|
||||
|
||||
enum
|
||||
enum TupleLengthType
|
||||
{
|
||||
length = Type::length
|
||||
};
|
||||
@ -711,7 +711,7 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,NullTypeList>
|
||||
{
|
||||
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>::HeadType Type;
|
||||
|
||||
enum
|
||||
enum TupleLengthType
|
||||
{
|
||||
length = Type::length
|
||||
};
|
||||
@ -806,7 +806,7 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12, NullTypeList>
|
||||
{
|
||||
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>::HeadType Type;
|
||||
|
||||
enum
|
||||
enum TupleLengthType
|
||||
{
|
||||
length = Type::length
|
||||
};
|
||||
@ -898,7 +898,7 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,NullTypeList>
|
||||
{
|
||||
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>::HeadType Type;
|
||||
|
||||
enum
|
||||
enum TupleLengthType
|
||||
{
|
||||
length = Type::length
|
||||
};
|
||||
@ -987,7 +987,7 @@ struct Tuple<T0, T1,T2,T3,T4,T5,T6,T7,T8,T9,T10, NullTypeList>
|
||||
{
|
||||
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>::HeadType Type;
|
||||
|
||||
enum
|
||||
enum TupleLengthType
|
||||
{
|
||||
length = Type::length
|
||||
};
|
||||
@ -1073,7 +1073,7 @@ struct Tuple<T0, T1,T2,T3,T4,T5,T6,T7,T8,T9, NullTypeList>
|
||||
{
|
||||
typedef typename TypeListType<T0, T1,T2,T3,T4,T5,T6,T7,T8,T9>::HeadType Type;
|
||||
|
||||
enum
|
||||
enum TupleLengthType
|
||||
{
|
||||
length = Type::length
|
||||
};
|
||||
@ -1156,7 +1156,7 @@ struct Tuple<T0, T1,T2,T3,T4,T5,T6,T7,T8, NullTypeList>
|
||||
{
|
||||
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7,T8>::HeadType Type;
|
||||
|
||||
enum
|
||||
enum TupleLengthType
|
||||
{
|
||||
length = Type::length
|
||||
};
|
||||
@ -1236,7 +1236,7 @@ struct Tuple<T0, T1,T2,T3,T4,T5,T6,T7, NullTypeList>
|
||||
{
|
||||
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7>::HeadType Type;
|
||||
|
||||
enum
|
||||
enum TupleLengthType
|
||||
{
|
||||
length = Type::length
|
||||
};
|
||||
@ -1313,7 +1313,7 @@ struct Tuple<T0, T1,T2,T3,T4,T5,T6, NullTypeList>
|
||||
{
|
||||
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6>::HeadType Type;
|
||||
|
||||
enum
|
||||
enum TupleLengthType
|
||||
{
|
||||
length = Type::length
|
||||
};
|
||||
@ -1387,7 +1387,7 @@ struct Tuple<T0, T1,T2,T3,T4,T5, NullTypeList>
|
||||
{
|
||||
typedef typename TypeListType<T0,T1,T2,T3,T4,T5>::HeadType Type;
|
||||
|
||||
enum
|
||||
enum TupleLengthType
|
||||
{
|
||||
length = Type::length
|
||||
};
|
||||
@ -1458,7 +1458,7 @@ struct Tuple<T0, T1,T2,T3,T4, NullTypeList>
|
||||
{
|
||||
typedef typename TypeListType<T0,T1,T2,T3,T4>::HeadType Type;
|
||||
|
||||
enum
|
||||
enum TupleLengthType
|
||||
{
|
||||
length = Type::length
|
||||
};
|
||||
@ -1526,7 +1526,7 @@ struct Tuple<T0, T1,T2,T3, NullTypeList>
|
||||
{
|
||||
typedef typename TypeListType<T0,T1,T2,T3>::HeadType Type;
|
||||
|
||||
enum
|
||||
enum TupleLengthType
|
||||
{
|
||||
length = Type::length
|
||||
};
|
||||
@ -1591,7 +1591,7 @@ struct Tuple<T0, T1,T2, NullTypeList>
|
||||
{
|
||||
typedef typename TypeListType<T0,T1,T2>::HeadType Type;
|
||||
|
||||
enum
|
||||
enum TupleLengthType
|
||||
{
|
||||
length = Type::length
|
||||
};
|
||||
@ -1653,7 +1653,7 @@ struct Tuple<T0, T1, NullTypeList>
|
||||
{
|
||||
typedef typename TypeListType<T0,T1>::HeadType Type;
|
||||
|
||||
enum
|
||||
enum TupleLengthType
|
||||
{
|
||||
length = Type::length
|
||||
};
|
||||
@ -1711,7 +1711,7 @@ struct Tuple<T0, NullTypeList>
|
||||
{
|
||||
typedef TypeList<T0, NullTypeList> Type;
|
||||
|
||||
enum
|
||||
enum TupleLengthType
|
||||
{
|
||||
length = Type::length
|
||||
};
|
||||
|
@ -64,12 +64,24 @@ TaskManager::~TaskManager()
|
||||
|
||||
void TaskManager::start(Task* pTask)
|
||||
{
|
||||
TaskPtr pAutoTask(pTask); // take ownership immediately
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
pTask->setOwner(this);
|
||||
pTask->setState(Task::TASK_STARTING);
|
||||
_taskList.push_back(TaskPtr(pTask));
|
||||
_threadPool.start(*pTask, pTask->name());
|
||||
pAutoTask->setOwner(this);
|
||||
pAutoTask->setState(Task::TASK_STARTING);
|
||||
_taskList.push_back(pAutoTask);
|
||||
try
|
||||
{
|
||||
_threadPool.start(*pAutoTask, pAutoTask->name());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Make sure that we don't act like we own the task since
|
||||
// we never started it. If we leave the task on our task
|
||||
// list, the size of the list is incorrect.
|
||||
_taskList.pop_back();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,11 +33,13 @@
|
||||
#include "TaskManagerTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/TaskManager.h"
|
||||
#include "Poco/Task.h"
|
||||
#include "Poco/TaskNotification.h"
|
||||
#include "Poco/NotificationCenter.h"
|
||||
#include "Poco/Thread.h"
|
||||
#include "Poco/ThreadPool.h"
|
||||
#include "Poco/Event.h"
|
||||
#include "Poco/Observer.h"
|
||||
#include "Poco/Exception.h"
|
||||
@ -54,9 +56,11 @@ using Poco::TaskFailedNotification;
|
||||
using Poco::TaskProgressNotification;
|
||||
using Poco::TaskCustomNotification;
|
||||
using Poco::Thread;
|
||||
using Poco::ThreadPool;
|
||||
using Poco::Event;
|
||||
using Poco::Observer;
|
||||
using Poco::Exception;
|
||||
using Poco::NoThreadAvailableException;
|
||||
using Poco::SystemException;
|
||||
using Poco::NullPointerException;
|
||||
using Poco::AutoPtr;
|
||||
@ -460,6 +464,36 @@ void TaskManagerTest::testMultiTasks()
|
||||
}
|
||||
|
||||
|
||||
void TaskManagerTest::testCustomThreadPool()
|
||||
{
|
||||
ThreadPool tp(2, 5, 120);
|
||||
TaskManager tm(tp);
|
||||
|
||||
// fill up the thread pool
|
||||
for (int i=0; i<tp.capacity(); ++i)
|
||||
{
|
||||
tm.start(new SimpleTask);
|
||||
}
|
||||
assert (tp.allocated() == tp.capacity());
|
||||
assert (tm.count() == tp.allocated());
|
||||
|
||||
// the next one should fail
|
||||
try
|
||||
{
|
||||
tm.start(new SimpleTask);
|
||||
failmsg("thread pool exhausted - must throw exception");
|
||||
}
|
||||
catch (NoThreadAvailableException const&)
|
||||
{
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
failmsg("wrong exception thrown");
|
||||
}
|
||||
|
||||
assert (tm.count() == tp.allocated());
|
||||
}
|
||||
|
||||
void TaskManagerTest::setUp()
|
||||
{
|
||||
}
|
||||
@ -479,6 +513,7 @@ CppUnit::Test* TaskManagerTest::suite()
|
||||
CppUnit_addTest(pSuite, TaskManagerTest, testError);
|
||||
CppUnit_addTest(pSuite, TaskManagerTest, testMultiTasks);
|
||||
CppUnit_addTest(pSuite, TaskManagerTest, testCustom);
|
||||
CppUnit_addTest(pSuite, TaskManagerTest, testCustomThreadPool);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ public:
|
||||
void testError();
|
||||
void testCustom();
|
||||
void testMultiTasks();
|
||||
void testCustomThreadPool();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
Loading…
x
Reference in New Issue
Block a user