Esempio n. 1
0
void SystemInfo::detectThreads() {
  // Threads type
#ifdef _WIN32
  threadsType = ThreadsType::WINDOWS_THREADS;

#elif __linux__
  // Test for LinuxThreads which has a different PID for each thread
  struct TestThread : public Thread {
    unsigned pid;
    TestThread() : pid(0) {}
    void run() {pid = SystemUtilities::getPID();}
  };

  TestThread testThread;
  testThread.start();
  testThread.join();

  if (testThread.pid != SystemUtilities::getPID())
    threadsType = ThreadsType::LINUX_THREADS;
  else threadsType = ThreadsType::POSIX_THREADS;

#else // __linux__
  // Assume POSIX
  threadsType = ThreadsType::POSIX_THREADS;
#endif
}
Esempio n. 2
0
void ThreadTest::thread_test01()
{
	TestThread t;
	t.start();

	::usleep(1000);

	t.stop();
	t.join();

	CPPUNIT_ASSERT_EQUAL(1, (int)t._finally);
}
Esempio n. 3
0
void Run(){

	//Test join after thread has finished
	{
		TestThread t;

		t.start();

		nitki::Thread::sleep(2000);

		t.join();
	}



	//Test join before thread has finished
	{
		TestThread t;

		t.start();

		t.join();
	}
}