void TMultiplexingServer::deleteActionContext()
{
    TActionWorker *worker = qobject_cast<TActionWorker *>(sender());
    Q_CHECK_PTR(worker);
    deletePointer(worker);
    worker->deleteLater();
    threadCounter.fetchAndAddOrdered(-1);
}
void TWorkerStarter::startWorker(int fd, const QByteArray &request, const QString &address)
{
    //
    // Create worker threads in main thread for signal/slot mechanism!
    //
    TActionWorker *worker = new TActionWorker(fd, THttpRequest(request, QHostAddress(address)));
    connect(worker, SIGNAL(finished()), multiplexingServer, SLOT(deleteActionContext()));
    multiplexingServer->insertPointer(worker);
    worker->start();
}
void TEpollHttpSocket::startWorker()
{
    tSystemDebug("TEpollHttpSocket::startWorker");

    TActionWorker *worker = new TActionWorker(this);
    worker->moveToThread(Tf::app()->thread());
    connect(worker, SIGNAL(finished()), this, SLOT(releaseWorker()));
    ++myWorkerCounter; // count-up
    worker->start();
}
void TEpollHttpSocket::releaseWorker()
{
    tSystemDebug("TEpollHttpSocket::releaseWorker");

    TActionWorker *worker = qobject_cast<TActionWorker *>(sender());
    if (worker) {
        worker->deleteLater();
        --myWorkerCounter;  // count-down

        if (deleting.load()) {
            TEpollSocket::deleteLater();
        } else {
            if (pollIn.exchange(false)) {
                TEpoll::instance()->modifyPoll(this, (EPOLLIN | EPOLLOUT | EPOLLET));  // reset
            }
        }
    }
}