当前位置: 首页>>代码示例>>C++>>正文


C++ IThread类代码示例

本文整理汇总了C++中IThread的典型用法代码示例。如果您正苦于以下问题:C++ IThread类的具体用法?C++ IThread怎么用?C++ IThread使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IThread类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: tick

	virtual void tick() {
		switch( style ) {
			case 0: {	// divizion by zero
				int a = 10;
				int b = 3;
				b-=3;
				a /= b;
				break;
					}
			case 1: {	// throw (int) exception
				throw 0;
				break;
					}

			case 2: {	// NULL pointer with vtable
				IThread *thread = NULL;
				thread->isActive();
				break;
					}

			case 3: {	// invalid pointer with vtable
				IThread *thread = (IThread *)0x335337L;
				thread->isActive();
				break;
					}

			case 4: {
				mykillingstackmachine(1, 2, 3, 4, 5, 6);
				break;
					}
		}
	}
开发者ID:zolter,项目名称:Source,代码行数:32,代码来源:threads.cpp

示例2: runtime_error

UTILSRUNTIME_API ITimer* Utils::Thread::CreateTimer(unsigned long millisec_interval, bool bEnable/* = true*/)
{
	IThread *pThread = Utils::Thread::GetCurrentThread();
	if (pThread == NULL)
		throw std::runtime_error("No thread object detected.");
	return pThread->NewTimer(millisec_interval, bEnable);
}
开发者ID:wyrover,项目名称:ESB,代码行数:7,代码来源:TimerImp.cpp

示例3: TEST

TEST(IThread, Test1) {
  class ThreadHandle: public IThread {
   public:
    ThreadHandle():num(1) {}
    virtual ~ThreadHandle() {}
   private:
   public:
    virtual void run() {
      ASSERT_EQ(num, 1u);
      num = 2;
    }
   public:
    size_t num;
  };
  {
    ThreadHandle thr;
    thr.start();
    thr.join();
    ASSERT_EQ(thr.num, 2u);
  }
  {
    IThread* ptr = new ThreadHandle();
    ptr->start();
    ptr->join();
    delete ptr;
  }
}
开发者ID:sunnyss12,项目名称:limonp,代码行数:27,代码来源:TThread.cpp

示例4: main

int main(int argc, char* argv[])
{
  try
    {
      IThread* serverThread = new Thread;
      IThread* clientThread = new Thread;

      ServerData sdata;
      sdata.isServer = (argc >= 2);
      sdata.serverThread = serverThread;
      serverThread->run(serverCallback, &sdata);

      ClientData cdata;
      cdata.isServer = (argc >= 2);
      cdata.login = "Unknown";
      if (argc >= 2)
	cdata.login = argv[1];
      cdata.clientThread = clientThread;
      if (sdata.isServer)
	sleep(2);
      clientThread->run(clientCallback, &cdata);

      clientThread->wait();
      delete clientThread;
      delete serverThread;
    }
  catch (IThread::Exception& e)
    {
      std::cerr << "Babel error: " << e.what() << std::endl; 
    }
  std::cout << "Bye" << std::endl;
  return 0;
}
开发者ID:Bootz,项目名称:VoIP_Project_archive,代码行数:33,代码来源:main.cpp

示例5: GetMaxThreadsPerFrame

unsigned int BaseWorker::RunFrame()
{
	unsigned int done = 0;
	unsigned int max = GetMaxThreadsPerFrame();
	SWThreadHandle *swt = NULL;
	IThread *pThread = NULL;

	while (done < max)
	{
		if ((swt=PopThreadFromQueue()) == NULL)
		{
			break;
		}
		pThread = swt->pThread;
		swt->m_state = Thread_Running;
		pThread->RunThread(swt);
		swt->m_state = Thread_Done;
		pThread->OnTerminate(swt, false);
		if (swt->m_params.flags & Thread_AutoRelease)
		{
			delete swt;
		}
		done++;
	}

	return done;
}
开发者ID:asceth,项目名称:synapi,代码行数:27,代码来源:BaseWorker.cpp

示例6: getThreadThrowIfNotStarted

void Server::stop() {
	IThread* pThread = getThreadThrowIfNotStarted();
	if ( ! pThread->isAlive() ) {
		cleanUp();
	} else {
		runnable->getWindowController()->close();
	}
}
开发者ID:robot-aquila,项目名称:wquik,代码行数:8,代码来源:Server.cpp

示例7: Thread_wrapper

void*
Thread_wrapper( void* self )
{
	IThread* ithread = (IThread*) self;
	LPTHREAD_START_ROUTINE callback = (LPTHREAD_START_ROUTINE) ithread->callback;

	ithread->ret = (DWORD) ithread->callback( ithread->arg );
	ExitThread( ithread->ret );
}
开发者ID:danielbradley,项目名称:Build,代码行数:9,代码来源:Thread.c

示例8: main

int main(int /*argc*/, char* /*argv*/ [])
{
  IThread* mainThread = IThread::createThread(mainProc, (void*)"main");
  mainThread->run();
  mainThread->join();
  printf("main end\n");
  IThread::deleteThread(mainThread);
  return 0;
}
开发者ID:h-godai,项目名称:ssa,代码行数:9,代码来源:unittest.cpp

示例9: srand

THREADPROC IThread::__ThreadProc(void* lParam) 
{
    srand( (unsigned)time( NULL ) + (unsigned)IThread::s_ThreadCount );
    IThread* pThread = (IThread *)lParam;
    IThread::s_ThreadCount++;
    pThread->_Run();
    pThread->OnExit();
    IThread::s_ThreadCount--;
    return NULL;
}
开发者ID:soho2515,项目名称:AsynRedisOperate,代码行数:10,代码来源:IThread.cpp

示例10: startStatThread

void startStatThread()
{
	if(startStat)
	{
		curl_global_init(CURL_GLOBAL_ALL);
		//nlinfo("startStatThread");
		CStatThread *statThread = new CStatThread();
		IThread	*thread = IThread::create (statThread);
		nlassert (thread != NULL);
		thread->start ();
	}
}
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:12,代码来源:init_main_loop.cpp

示例11: startWebigNotificationThread

void startWebigNotificationThread()
{
	static bool startedWebigNotificationThread = false;
	if(!startedWebigNotificationThread)
	{
		curl_global_init(CURL_GLOBAL_ALL);
		//nlinfo("startStatThread");
		CWebigNotificationThread *webigThread = new CWebigNotificationThread();
		IThread	*thread = IThread::create (webigThread);
		nlassert (thread != NULL);
		thread->start ();
		startedWebigNotificationThread = true;
	}
}
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:14,代码来源:group_html_webig.cpp

示例12: init

IThread *ThreadHolder::current()
{
	init();

	IThread * thread = m_currentThread;
	if (thread == NULL)
		return DummySphereThread::getInstance();

#ifdef _WIN32
	ASSERT(thread->getId() == ::GetCurrentThreadId());
#else
	ASSERT(thread->getId() == (unsigned)pthread_self());
#endif
	return thread;
}
开发者ID:DarkLotus,项目名称:Source,代码行数:15,代码来源:threads.cpp

示例13: ThreadWin

ThreadPool::ThreadPool(int const nbThread)
{
    IThread *thread;
    for (unsigned int i=0; i < nbThread; ++i)
    {
#ifdef _WIN32
		thread = new ThreadWin();
#else
		thread = new Thread();
#endif
        GameEngine *engine = new GameEngine();
        thread->create(reinterpret_cast<void *>(&launchGameEngine), engine);
        _pool.push_back(std::pair<IThread*, GameEngine *>(thread, engine));
    }
}
开发者ID:athomaj,项目名称:RType,代码行数:15,代码来源:ThreadPool.cpp

示例14: main

/*
 * 1 scénario / niveau (map)
 * 
 * Scénario:
 * Type obj, cycle, coord
 * 
 * Script obj:
 * debut cycle, fin cycle, coord vecteur directeur, 
 * 
 * type tir, frequence
 * 
 * scenario contient par cycle le niveau
 * 
 */
int main(int argc, char** argv)
{
	(void)argc;
	(void)argv;
#ifdef WIN32
	std::cout << "Win32" << std::endl;
#elif _WIN32
	std::cout << "_Win32" << std::endl;
#elif __WIN32
	std::cout << "__Win32" << std::endl;
#elif __CYGWIN__
	std::cout << "cygwin" << std::endl;
#else
	std::cout << "Autre" << std::endl;
#endif
//	GameObject* gg = new GameObject;
	IThread *thread = new Thread();
    IThread *manag = new Thread();
    IServer *server = new ServerTCP();
	
	thread->create(reinterpret_cast<void*>(&launchServer), server);
    manag->create(reinterpret_cast<void*>(&launchManager), server);
    manag->join();
	
//	CrossLoader *loader = new CrossLoader();
//		
//	try
//	{
//		loader->checkLibraries();
//	}
//	catch (std::exception &e)
//	{
//		std::cout << e.what() << std::endl;
//	}
//	loader->LoadLibrary("tim.dll");
//	loader->LoadSymbole();
//	loader->CloseLibrary();
//	Parser *parser = new Parser();
//	try
//	{
//		parser->load("Starwars");
//	}
//	catch (std::exception &e)
//	{
//		std::cout << e.what() << std::endl;
//	}
	return 0;
}
开发者ID:athomaj,项目名称:RType,代码行数:62,代码来源:main.cpp

示例15: clean

 bool SimpleThreadpoolBehaviour::clean()
 {
     ThreadCollectionIter aIter = _pool.begin();
     IThread * aTemp = 0;
     for(;aIter != _pool.end(); aIter++)
     {
         aTemp = (*aIter);
         if(aTemp)
         {
             aTemp->stop();
             delete aTemp;
             (*aIter) = 0;
             aTemp = 0;
         }
     }
     return true;
 }
开发者ID:patricio-astudillo,项目名称:gea,代码行数:17,代码来源:simple-threadpool-behaviour.cpp


注:本文中的IThread类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。