コード例 #1
0
int main (int argc, char* argv[]) {
	//Shared data
	bool running = true;
	std::string callbackString = "";
	int callbackStringLength = 0;

	Barrier newInput;
	Barrier newLength;
	Barrier finishedOutput;

	//Thread handler initialization
	InputHandler inputHandler(&running, &callbackString, &newInput, &finishedOutput);
	LogicHandler logicHandler(&running, &callbackString, &callbackStringLength, &newInput, &newLength);
	OutputHandler outputHandler(&running, &callbackString, &callbackStringLength, &newLength, &finishedOutput);

	//Threads
	std::thread inputThread(&InputHandler::run, &inputHandler);
	std::thread logicThread(&LogicHandler::run, &logicHandler);
	std::thread outputThread(&OutputHandler::run, &outputHandler);

	//Close program
	inputThread.join();
	logicThread.join();
	outputThread.join();
	return 0;
}
コード例 #2
0
ファイル: main.cpp プロジェクト: Jsfumato/GameServerStudy
int main()
{
	NLogicLib::Main main;
	main.Init();

	std::thread logicThread([&]() { 		
		main.Run(); }
	);
	
	std::cout << "press any key to exit...";
	getchar();

	main.Stop();
	logicThread.join();

	return 0;
}
コード例 #3
0
ファイル: main.cpp プロジェクト: Manbeardo/Era-of-Kings
int main()
{
    sf::Thread inputThread(&inputThreadFunc);
    sf::Thread renderThread(&renderThreadFunc);
    sf::Thread logicThread(&logicThreadFunc);

    inputThread.Launch();
    // wait for input thread to create window
    while(!global.windowOpen);
    renderThread.Launch();
    logicThread.Launch();

    inputThread.Wait();
    renderThread.Wait();
    logicThread.Wait();

    global.window->Close();
    delete global.window;

    return EXIT_SUCCESS;
}