void TApplicationServer::incomingConnection(int socketDescriptor)
{
    T_TRACEFUNC("socketDescriptor: %d", socketDescriptor);
 
    switch ( Tf::app()->multiProcessingModule() ) {
    case TWebApplication::Thread:
        for (;;) {
            if (actionContextCount() < maxServers) {
                TActionThread *thread = new TActionThread(socketDescriptor);
                connect(thread, SIGNAL(finished()), this, SLOT(deleteActionContext()));
                insertPointer(thread);
                thread->start();
                break;
            }
            Tf::msleep(1);
            qApp->processEvents(QEventLoop::ExcludeSocketNotifiers);
        }
        break;

    case TWebApplication::Prefork: {
        close();  // Closes the listening port
        TActionForkProcess *process = new TActionForkProcess(socketDescriptor);
        connect(process, SIGNAL(finished()), this, SLOT(deleteActionContext()));
        insertPointer(process);
        process->start();
        break; }

    default:
        break;
    }
}
void TThreadApplicationServer::incomingConnection(qintptr socketDescriptor)
{
    for (;;) {
        tSystemDebug("incomingConnection  sd:%lld  thread count:%d  max:%d", (qint64)socketDescriptor, TActionThread::threadCount(), maxThreads);
        if (TActionThread::threadCount() < maxThreads) {
            TActionThread *thread = new TActionThread(socketDescriptor, maxThreads);
            connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
            thread->start();
            break;
        }
        //Tf::msleep(1);
        qApp->processEvents(QEventLoop::ExcludeSocketNotifiers);
    }
}