本文整理汇总了C++中IThread::create方法的典型用法代码示例。如果您正苦于以下问题:C++ IThread::create方法的具体用法?C++ IThread::create怎么用?C++ IThread::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IThread
的用法示例。
在下文中一共展示了IThread::create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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));
}
}
示例3: sizeof
void ManageRoom::handleCreateGame(void *buffer, Client *cl)
{
t_TCPCreate *create;
create = (t_TCPCreate *)buffer;
Room *room = new Room;
room->setGameId(this->currentGameId);
room->setNbMax(create->nb_max);
room->setName(create->name_game);
std::cout << "Creating room=" << room->getName() << std::endl;
char id = room->addClient(cl);
std::cout << (int)id << std::endl;
this->listRoom[this->currentGameId++] = room;
int i = 0;
int len;
const char *str = cl->getName().c_str();
ISocket *sock;
t_TCPPlayer Player;
//On prépare le packet pour prévenir le joueur de sa connection à la partie créée
while (str[i])
Player.name[i] = str[i++];
Player.name[i] = '\0';
Player.player_id = id;
Player.status = NOT_READY;
Player.header.packetSize = sizeof(Player);
Player.header.type = PLAYER;
sock = cl->getSocket();
this->_access[sock->getIp()] = room;
IThread *th = new WinThread;
std::cout <<"LOOOOOOOOOOOL" << std::endl;
th->create(initGame, room);
std::cout << "LOOOL2"<< std::endl;
if ((len = sock->sendBinary(&Player, sizeof(Player))) < 0)
std::cout << "Error while sending Create" << std::endl;
}