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
int main(int argc, char** argv)
{ 
	InitDTLibrary();
	try
	{	
		vector<TestThread*> threads;
		for (int i = 0; i < 1; i++) {
			TestThread *thread = new TestThread (argc, argv);
			threads.push_back (thread);
			
			thread->start();
		}
		
		for (int j=0; j < threads.size(); j++) {
			threads[j]->join();
		}
		
	}
	catch(Poco::Exception &e)
	{
		cout << e.what() << endl;
	}
	catch (Exception &exp)
	{
		cout << exp.toString().getCStr() << endl;
	}
	
	return 0;
}
Esempio n. 3
0
int main(int argc, char** argv)
{
	TestThread t;
	t.start();
	t.block();
	std::cout << "(Main)" << std::endl;
	t.cancel();
	return 0;
}
Esempio n. 4
0
void ThreadTest::thread_test01()
{
	TestThread t;
	t.start();

	::usleep(1000);

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

	CPPUNIT_ASSERT_EQUAL(1, (int)t._finally);
}
Esempio n. 5
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();
	}
}
    void cancelExport()
    {
        TestThread cancelThread;
        QLandmarkFileHandlerGpx handler(&(cancelThread.m_cancel));
        QLandmark lm;
        QList<QLandmark> lms;
        for (int i=0; i < 50000; ++i) {
            lm.setName(QString("LM%1").arg(0));
            lms.append(lm);
        }

        handler.setWaypoints(lms);
        cancelThread.start();
        QFile file(m_exportFile);
        QVERIFY(!handler.exportData(&file));
        QCOMPARE(handler.error(), QLandmarkManager::CancelError);
        cancelThread.wait();
    }
Esempio n. 7
0
void test_thread ()
{
	TestThread thread;
	thread.start();
	thread.wait();
}