[AGENT++] Agentpp::QueuedThreadPool does not executes its queue entries

Claus Klein claus.klein at arcormail.de
Tue Sep 12 07:09:06 CEST 2017


Hi Frank,

thank you for your response.

With the time I know the caves with this API ;-)

I have tested a Version with no additional queue thread. So it must not started and only terminalte() should be use to stop it.

What do you thing about this?

void QueuedThreadPool::run()
{
    Thread::lock();
    go = true;
    while (go) {
        if (!queue.empty()) {
            Runnable* t = queue.front();
            if (t) {
                LOG_BEGIN(loggerModuleName, DEBUG_LOG | 1);
                LOG("queue.pop");
                LOG_END;
                queue.pop();
                assign(t);
            }
        }
#ifdef AGENTPP_QUEUED_TRHEAD_POOL_USE_QUEUE_THREAD
        Thread::wait(123);  // ms
#else
        break;
#endif
    }
    Thread::unlock();
}

void QueuedThreadPool::idle_notification()
{

#ifdef AGENTPP_QUEUED_TRHEAD_POOL_USE_QUEUE_THREAD
    LOG_BEGIN(loggerModuleName, DEBUG_LOG | 1);
    LOG("notify");
    LOG_END;

    Thread::lock();
    Thread::notify();
    Thread::unlock();
#else
    //NOTE: the additional thread can be prevented by call here:
    run();
#endif

    ThreadPool::idle_notification();
}


Best Regards

Claus

> On 12 Sep 2017, at 00:16, Frank Fock <fock at agentpp.com> wrote:
> 
> The QueuedThreadPool was never intended for the API end user.



More information about the AGENTPP mailing list