本文整理汇总了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;
}
}
}
示例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);
}
示例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;
}
}
示例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;
}
示例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;
}
示例6: getThreadThrowIfNotStarted
void Server::stop() {
IThread* pThread = getThreadThrowIfNotStarted();
if ( ! pThread->isAlive() ) {
cleanUp();
} else {
runnable->getWindowController()->close();
}
}
示例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 );
}
示例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;
}
示例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;
}
示例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 ();
}
}
示例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;
}
}
示例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;
}
示例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));
}
}
示例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;
}
示例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;
}