Esempio n. 1
0
void Service::start()
{
    try
    {
        sp_modules_->loadModules();

        observers_.notify(&IObserver::onServerPrepared);
        if (!isShutdown())
            run();
    }
    catch (exception& e)
    {
        shutdown_now = true;
        try
        {
            observers_.notify(&IObserver::onServerClosing);
            onShutdown();
        }
        catch (...)
        {
        }

        throw;
    }

    waitForShutdown();
}
    //-------------------------------------------------------------------------
    bool RTPReceiverChannelAudio::handlePacket(RTPPacketPtr packet)
    {
      UseChannelResourcePtr channelResource;

      {
        AutoRecursiveLock lock(*this);
        if (isShuttingDown() || isShutdown())
          return false;
        channelResource = mChannelResource;
        bool shouldQueue = false;
        if (!channelResource)
          shouldQueue = true;
        if (mQueuedRTP.size() > 0)
          shouldQueue = true;
        if (shouldQueue) {
          mQueuedRTP.push(packet);
          if (1 == mQueuedRTP.size())
            IWakeDelegateProxy::create(mThisWeak.lock())->onWake();
          return true;
        }
      }

      if (!channelResource) return true;
      return channelResource->handlePacket(*packet);
    }
void UIMainEventListeningThread::run()
{
    /* Initialize COM: */
    COMBase::InitializeCOM(false);

    /* Copy source wrapper to this thread: */
    CEventSource comSource = m_comSource;
    /* Copy listener wrapper to this thread: */
    CEventListener comListener = m_comListener;

    /* While we are not in shutdown: */
    while (!isShutdown())
    {
        /* Fetch the event from the queue: */
        CEvent comEvent = comSource.GetEvent(comListener, 500);
        if (!comEvent.isNull())
        {
            /* Process the event and tell the listener: */
            comListener.HandleEvent(comEvent);
            if (comEvent.GetWaitable())
                comSource.EventProcessed(comListener, comEvent);
        }
    }

    /* Cleanup COM: */
    COMBase::CleanupCOM();
}
Esempio n. 4
0
void SessionTimer::thread()
{
    SIPSDK_INFOTRACE("SessionTimer::thread");

    // Do this every 0.2 second
    while(!isShutdown())
    {
        SipCallMgr::GetInstance()->DetectCallLiveOrDead();
        usleep(200000);
    }

    SIPSDK_INFOTRACE("SessionTimer::thread stop.");
}
Esempio n. 5
0
//=============================================================================
// METHOD: SPELLthreadWorker::run()
//=============================================================================
void SPELLthreadWorker::run()
{
	while(true)
	{
		m_newWork.wait();
		m_newWork.clear();
		if (!isShutdown())
		{
			getWork()->doWork();
		}
		deleteWork();
	}
}
Esempio n. 6
0
void TaskThread::processTasksLoop() {
    while (!m_shutdown) {
        auto m_actualTaskQueue = m_taskQueue.lock();

        if (m_actualTaskQueue && !m_actualTaskQueue->isShutdown()) {
            auto task = m_actualTaskQueue->pop();

            if (task) {
                task->operator()();
            }
        } else {
            // Since we could not get a shared pointer to the the TaskQueue, it must have been destroyed.
            // The thread must shut down.
            m_shutdown = true;
        }
    }
}
void ThreadIdentifierData::destruct(void* data)
{
    if (isShutdown())
        return;

    ThreadIdentifierData* threadIdentifierData = static_cast<ThreadIdentifierData*>(data);
    ASSERT(threadIdentifierData);

    if (threadIdentifierData->m_isDestroyedOnce) {
        delete threadIdentifierData;
        return;
    }

    threadIdentifierData->m_isDestroyedOnce = true;
    // Re-setting the value for key causes another destruct() call after all other thread-specific destructors were called.
    pthread_setspecific(m_key, threadIdentifierData);
}
void ThreadIdentifierData::destruct(void* data)
{
    if (isShutdown())
        return;

    ThreadIdentifierData* threadIdentifierData = static_cast<ThreadIdentifierData*>(data);
#if defined(SBROWSER_PLM_P140704_01923)
	if(!threadIdentifierData)
		return;
#else
    ASSERT(threadIdentifierData);
#endif

    if (threadIdentifierData->m_isDestroyedOnce) {
        delete threadIdentifierData;
        return;
    }

    threadIdentifierData->m_isDestroyedOnce = true;
    // Re-setting the value for key causes another destruct() call after all other thread-specific destructors were called.
    pthread_setspecific(m_key, threadIdentifierData);
}
 //-----------------------------------------------------------------------
 bool TransportStream::isWriterReady() const
 {
   AutoRecursiveLock lock(getLock());
   if (isShutdown()) return false;
   return mReaderReady;
 }