[AGENT++] Agentpp:: QueuedThreadPool queue is scheduled in wrong order
Claus Klein
claus.klein at arcormail.de
Wed Sep 13 23:13:39 CEST 2017
Hi Frank,
I’m wondering if it is intended that the queue is scheduled in wrong (random) order depending on the load?
The problem is at the QueuedThreadPool::run():
* after notify(), a queue entry is removed and assign() called.
* If the pool is busy again, because execute() was called:
* The task is queued again with queue.add(), but at the end!
* assign() calls notify() after that, so this procedure starts again.
See log below.
With regards,
Claus
Running 1 test case...
Entering test suite "Threads"
Entering test case "QueuedThreadPool_test"
: (1)DEBUG : TaskManager: thread started
: (1)ERROR : Thread: thread already running!
queuedThreadPool.size: 1
/Users/clausklein/Workspace/cpp/AgentProV4/threads_test.cpp:119: info: check queuedThreadPool.size() == 1 passed
/Users/clausklein/Workspace/cpp/AgentProV4/threads_test.cpp:120: info: check queuedThreadPool.stack_size() == 0x10000 passed
/Users/clausklein/Workspace/cpp/AgentProV4/threads_test.cpp:121: info: check queuedThreadPool.is_idle() passed
: (1)DEBUG : QueuedThreadPool::assign(IDLE):: task manager found
: (2)DEBUG : TaskManager: after notify
: (1)DEBUG : QueuedThreadPool::assign(BUSY): queue.add()
: (1)DEBUG : QueuedThreadPool::assign(BUSY): queue.add()
/Users/clausklein/Workspace/cpp/AgentProV4/threads_test.cpp:126: info: check !queuedThreadPool.is_idle() passed
: (1)DEBUG : QueuedThreadPool::run(IDLE): queue.removeFirst()
: (1)DEBUG : QueuedThreadPool::assign(BUSY): queue.add()
: (1)DEBUG : QueuedThreadPool::assign(BUSY): queue.add()
: (1)DEBUG : QueuedThreadPool::assign(BUSY): queue.add()
: (1)DEBUG : QueuedThreadPool::assign(BUSY): queue.add()
: (1)DEBUG : QueuedThreadPool::assign(BUSY): queue.add()
: (1)DEBUG : QueuedThreadPool::run(IDLE): queue.removeFirst()
: (1)DEBUG : QueuedThreadPool::assign(BUSY): queue.add()
: (1)DEBUG : QueuedThreadPool::assign(BUSY): queue.add()
: (1)DEBUG : QueuedThreadPool::assign(BUSY): queue.add()
queuedThreadPool.queue_length: 8
: (1)DEBUG : QueuedThreadPool::run(IDLE): queue.removeFirst()
: (1)DEBUG : QueuedThreadPool::assign(BUSY): queue.add()
virtual void TestTask::run() called with: 1 Hi again.
: (1)DEBUG : QueuedThreadPool::run(IDLE): queue.removeFirst()
: (1)DEBUG : QueuedThreadPool::assign(IDLE):: task manager found
: (2)DEBUG : TaskManager: after notify
virtual void TestTask::run() called with: 4 Queueing ...
: (1)DEBUG : QueuedThreadPool::run(IDLE): queue.removeFirst()
: (1)DEBUG : QueuedThreadPool::assign(IDLE):: task manager found
: (2)DEBUG : TaskManager: after notify
virtual void TestTask::run() called with: 5 Queueing ...
: (1)DEBUG : QueuedThreadPool::run(IDLE): queue.removeFirst()
: (1)DEBUG : QueuedThreadPool::assign(IDLE):: task manager found
: (2)DEBUG : TaskManager: after notify
virtual void TestTask::run() called with: 6 Queueing ...
: (1)DEBUG : QueuedThreadPool::run(IDLE): queue.removeFirst()
: (1)DEBUG : QueuedThreadPool::assign(IDLE):: task manager found
: (2)DEBUG : TaskManager: after notify
virtual void TestTask::run() called with: 7 Queueing ...
: (1)DEBUG : QueuedThreadPool::run(IDLE): queue.removeFirst()
: (1)DEBUG : QueuedThreadPool::assign(IDLE):: task manager found
: (2)DEBUG : TaskManager: after notify
virtual void TestTask::run() called with: 3 Under full load!
: (1)DEBUG : QueuedThreadPool::run(IDLE): queue.removeFirst()
: (1)DEBUG : QueuedThreadPool::assign(IDLE):: task manager found
: (2)DEBUG : TaskManager: after notify
virtual void TestTask::run() called with: 8 Queueing ...
: (1)DEBUG : QueuedThreadPool::run(IDLE): queue.removeFirst()
: (1)DEBUG : QueuedThreadPool::assign(IDLE):: task manager found
: (2)DEBUG : TaskManager: after notify
virtual void TestTask::run() called with: 9 Queueing ...
: (1)DEBUG : QueuedThreadPool::run(IDLE): queue.removeFirst()
: (1)DEBUG : QueuedThreadPool::assign(IDLE):: task manager found
: (2)DEBUG : TaskManager: after notify
virtual void TestTask::run() called with: 2 Queueing starts.
outstanding tasks: 0
/Users/clausklein/Workspace/cpp/AgentProV4/threads_test.cpp:144: info: check TestTask::task_count() == 0 passed
: (4)DEBUG : Thread: joined thread successfully (tid): (123145302458368)
: (4)DEBUG : Thread: joined thread successfully (tid): (123145302380544)
: (1)DEBUG : TaskManager: thread stopped
/Users/clausklein/Workspace/cpp/AgentProV4/threads_test.cpp:147: info: check TestTask::task_count() == 0 passed
/Users/clausklein/Workspace/cpp/AgentProV4/threads_test.cpp:148: info: check TestTask::run_count() == 9 passed
expected msg: 4 Queueing ...
/Users/clausklein/Workspace/cpp/AgentProV4/threads_test.cpp:158: error in "QueuedThreadPool_test": check boost::hash_value(value) == boost::hash_value(msg) failed
expected msg: 5 Queueing ...
/Users/clausklein/Workspace/cpp/AgentProV4/threads_test.cpp:158: error in "QueuedThreadPool_test": check boost::hash_value(value) == boost::hash_value(msg) failed
expected msg: 6 Queueing ...
/Users/clausklein/Workspace/cpp/AgentProV4/threads_test.cpp:158: error in "QueuedThreadPool_test": check boost::hash_value(value) == boost::hash_value(msg) failed
expected msg: 7 Queueing ...
/Users/clausklein/Workspace/cpp/AgentProV4/threads_test.cpp:158: error in "QueuedThreadPool_test": check boost::hash_value(value) == boost::hash_value(msg) failed
expected msg: 8 Queueing ...
/Users/clausklein/Workspace/cpp/AgentProV4/threads_test.cpp:158: error in "QueuedThreadPool_test": check boost::hash_value(value) == boost::hash_value(msg) failed
expected msg: 9 Queueing ...
/Users/clausklein/Workspace/cpp/AgentProV4/threads_test.cpp:158: error in "QueuedThreadPool_test": check boost::hash_value(value) == boost::hash_value(msg) failed
Leaving test case "QueuedThreadPool_test"; testing time: 4269mks
Leaving test suite "Threads"
More information about the AGENTPP
mailing list