Example #1
0
void TaskQueue::run( )
{
    RunProlog();

    Task *pTask;

    LOG(VB_UPNP, LOG_INFO, "TaskQueue Thread Running.");

    while ( !m_bTermRequested )
    {
        // ------------------------------------------------------------------
        // Process Any Tasks that may need to be executed.
        // ------------------------------------------------------------------

        TaskTime ttNow;
        gettimeofday( (&ttNow), nullptr );

        if ((pTask = GetNextExpiredTask( ttNow )) != nullptr)
        {
            try
            {
                pTask->Execute( this );
                pTask->DecrRef();
            }
            catch( ... )
            {
                LOG(VB_GENERAL, LOG_ERR, "Call to Execute threw an exception.");
            }

        }
        // Make sure to throttle our processing.

        msleep( 100 );
    }

    RunEpilog();
}