Example #1
0
void CVideoChatServer::Release(void)
{
	m_bWantStop = true;
	m_recvEvent.Set();
	WaitForStop();

	if ( m_pTcpServer )
	{
		m_pTcpServer->ReleaseConnections();
		m_pTcpServer = NULL;
	}
}
Example #2
0
void CFileUpLoad::UnInit()
{
	m_bStop = TRUE;
	m_bConnect = FALSE;
	g_bFileConnect = false;
	m_bUpLoad = FALSE;

	g_pLogger->information("CFileUpLoad UnInit==>WaitForStop().");
	WaitForStop();
	g_pLogger->information("CFileUpLoad UnInit==>WaitForStop() completed.");

	if (m_pITcpClient)
	{
		m_pITcpClient->ReleaseConnections();
		m_pITcpClient = NULL;
	}

	mutexObj.Lock();
	std::list<stUpLoadAns*>::iterator it1 = m_listFile.begin();
	for (; it1 != m_listFile.end(); )
	{
		stUpLoadAns* itUp = *it1;
		it1 = m_listFile.erase(it1);
		SAFE_RELEASE(itUp);
	}
	m_listFile.clear();
	mutexObj.Unlock();
	// 	m_VecAns.clear();
	std::vector<stUpLoadAns*>::iterator it = m_VecAns.begin();
	for (; it != m_VecAns.end(); it++)
	{
		if (*it)
		{
			delete (*it);
			(*it) = NULL;
		}
	}
	std::list<pstUpLoadAddr>::iterator itAddr = m_UpLoadAddrList.begin();
	for (; itAddr != m_UpLoadAddrList.end();)
	{
		pstUpLoadAddr pUpLoadAddr = *itAddr;
		itAddr = m_UpLoadAddrList.erase(itAddr);
		SAFE_RELEASE(pUpLoadAddr);
	}
}
TEST(libbacktrace, ptrace_threads) {
  pid_t pid;
  if ((pid = fork()) == 0) {
    for (size_t i = 0; i < NUM_PTRACE_THREADS; i++) {
      pthread_attr_t attr;
      pthread_attr_init(&attr);
      pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);

      pthread_t thread;
      ASSERT_TRUE(pthread_create(&thread, &attr, PtraceThreadLevelRun, NULL) == 0);
    }
    ASSERT_NE(test_level_one(1, 2, 3, 4, NULL, NULL), 0);
    exit(1);
  }

  // Check to see that all of the threads are running before unwinding.
  std::vector<pid_t> threads;
  uint64_t start = NanoTime();
  do {
    usleep(US_PER_MSEC);
    threads.clear();
    GetThreads(pid, &threads);
  } while ((threads.size() != NUM_PTRACE_THREADS + 1) &&
      ((NanoTime() - start) <= 5 * NS_PER_SEC));
  ASSERT_EQ(threads.size(), static_cast<size_t>(NUM_PTRACE_THREADS + 1));

  ASSERT_TRUE(ptrace(PTRACE_ATTACH, pid, 0, 0) == 0);
  WaitForStop(pid);
  for (std::vector<int>::const_iterator it = threads.begin(); it != threads.end(); ++it) {
    // Skip the current forked process, we only care about the threads.
    if (pid == *it) {
      continue;
    }
    VerifyProcTest(pid, *it, ReadyLevelBacktrace, VerifyLevelDump);
  }
  ASSERT_TRUE(ptrace(PTRACE_DETACH, pid, 0, 0) == 0);

  kill(pid, SIGKILL);
  int status;
  ASSERT_EQ(waitpid(pid, &status, 0), pid);
}
Example #4
0
void CSoundGen::SelectChip(int Chip)
{
    if (m_bPlaying)
        StopPlayer();

    if (!WaitForStop()) {
        TRACE0("CSoundGen: Could not stop player!");
        return;
    }

    m_pAPU->SetExternalSound(Chip);

    // Enable internal channels after reset
    m_pAPU->Write(0x4015, 0x0F);
    m_pAPU->Write(0x4017, 0x00);

    // MMC5
    if (Chip & SNDCHIP_MMC5)
        m_pAPU->ExternalWrite(0x5015, 0x03);

}
Example #5
0
	ThreadBoost::~ThreadBoost()
	{
		RequestStop();
		WaitForStop();
	}
Example #6
0
SoccerField::~SoccerField()
{
	WaitForStop();
	boost::system::error_code error;

}
WheelController::~WheelController()
{
	Stop();
	WaitForStop();
}
Example #8
0
void MSDKBase::Stop()
{
    m_bWantToStop = true;
    WaitForStop();
}