//Entry point of program int WINAPI WinMain(HINSTANCE pHInstance, HINSTANCE pPrevHInstance, PSTR pSTR, int pCmdshow) { //Initialize scene & window scene = make_unique<Scene>(); window = make_unique<W_Window>(); window->Initialize(); //run the main loop map<int, vector<W_WindowInfo>> windowsInfo = { { 0, { { window->GetHWND(), window->GetWidth(), window->GetHeight() } } } }; std::function<void(void)> run = [&windowsInfo]()->void { scene->Run(windowsInfo); }; window->Run(run); //release all Release(); return EXIT_SUCCESS; }
void RunMain() { bool reload = false; while (!g_NZBGet || g_NZBGet->GetReloading()) { g_NZBGet = std::make_unique<NZBGet>(); g_NZBGet->Run(reload); reload = true; } g_NZBGet.reset(); }
void SudokuBaseParallelRunnerTest::test_Run() { constexpr NumberOfCores numberOfCoresSet[] = {1, 2}; for(auto num : numberOfCoresSet) { auto expected = setupFalseEvaluatorSet(); auto result = pRunner_->Run(num); CPPUNIT_ASSERT(pRunner_->evaluatorSet_.empty()); CPPUNIT_ASSERT_EQUAL(expected, result); expected = setupAnyTrueEvaluatorSet(); result = pRunner_->Run(num); CPPUNIT_ASSERT_EQUAL(expected, result); expected = setupFalseEvaluatorSet(); result = pRunner_->Run(num); CPPUNIT_ASSERT_EQUAL(expected, result); expected = setupTrueEvaluatorSet(); result = pRunner_->Run(num); CPPUNIT_ASSERT_EQUAL(expected, result); } return; }
void ScriptStreamerThread::runScriptStreamingTask( std::unique_ptr<v8::ScriptCompiler::ScriptStreamingTask> task, ScriptStreamer* streamer) { TRACE_EVENT1( "v8,devtools.timeline", "v8.parseOnBackground", "data", InspectorParseScriptEvent::data(streamer->scriptResourceIdentifier(), streamer->scriptURLString())); // Running the task can and will block: SourceStream::GetSomeData will get // called and it will block and wait for data from the network. task->Run(); streamer->streamingCompleteOnBackgroundThread(); MutexLocker locker(*s_mutex); ScriptStreamerThread* thread = shared(); if (thread) thread->taskDone(); // If thread is 0, we're shutting down. }
void SudokuParallelRunnerTest::test_Run() { #ifdef NO_PARALLEL constexpr TestType testTypeSet[] = {TestType::PUBLIC_FUNC, TestType::IMPL_FUNC}; #else constexpr TestType testTypeSet[] = {TestType::PUBLIC_FUNC, TestType::PROTECTED_FUNC, TestType::IMPL_FUNC}; #endif for(auto testType : testTypeSet) { constexpr NumberOfCores numberOfCoresSet[] = {1, 2, 4, 8}; for(auto num : numberOfCoresSet) { EvaluatorSet evaluatorSet; LoopCount count = setupEvaluatorSet(num, evaluatorSet) * num; switch(testType) { case TestType::PUBLIC_FUNC: pRunner_->Run(num); CPPUNIT_ASSERT(pRunner_->evaluatorSet_.empty()); break; case TestType::PROTECTED_FUNC: pRunner_->runParallel(evaluatorSet); break; case TestType::IMPL_FUNC: runFutureSet(evaluatorSet); break; default: break; } LoopCount countT = countT_; LoopCount countF = countT_; LoopCount countTotal = countTotal_; CPPUNIT_ASSERT_EQUAL(count, countT); CPPUNIT_ASSERT_EQUAL(count, countF); CPPUNIT_ASSERT_EQUAL(count * 2, countTotal); } } return; }
int send_message(int msg, const std::vector<int> &arguments) { assert(sim); HEXAPI_Status status; HEX_4u_t remote_msg = 0; status = sim->ReadSymbolValue("rpc_call", &remote_msg); if (status != HEX_STAT_SUCCESS) { printf("HexagonWrapper::ReadSymbolValue(rpcmsg) failed: %d\n", status); return -1; } if (write_memory(remote_msg, &msg, 4) != 0) { return -1; } // The arguments are individual numbered variables. for (size_t i = 0; i < arguments.size(); i++) { HEX_4u_t remote_arg = 0; std::string rpc_arg = "rpc_arg" + std::to_string(i); status = sim->ReadSymbolValue(rpc_arg.c_str(), &remote_arg); if (status != HEX_STAT_SUCCESS) { printf("HexagonWrapper::ReadSymbolValue(%s) failed: %d\n", rpc_arg.c_str(), status); return -1; } if (write_memory(remote_arg, &arguments[i], 4) != 0) { return -1; } } HEX_4u_t remote_ret = 0; status = sim->ReadSymbolValue("rpc_ret", &remote_ret); if (status != HEX_STAT_SUCCESS) { printf("HexagonWrapper::ReadSymbolValue(rpc_ret) failed: %d\n", status); return -1; } HEXAPI_CoreState state; if (msg == Message::Break) { // If we're trying to end the remote simulation, just run // until completion. HEX_4u_t result; state = sim->Run(&result); if (state != HEX_CORE_FINISHED) { printf("HexagonWrapper::Run failed: %d\n", state); return -1; } return 0; } else { // If we want to return and continue simulating, we execute // 1000 cycles at a time, until the remote indicates it has // completed handling the current message. do { HEX_4u_t cycles; state = sim->Step(1000, &cycles); if (read_memory(&msg, remote_msg, 4) != 0) { return -1; } if (msg == Message::None) { HEX_4u_t ret = 0; if (read_memory(&ret, remote_ret, 4)) { return -1; } return ret; } } while (state == HEX_CORE_SUCCESS); printf("HexagonWrapper::StepTime failed: %d\n", state); return -1; } }
int send_message(int msg, const std::vector<int> &arguments) { assert(sim); HEXAPI_Status status; HEX_4u_t remote_msg = 0; status = sim->ReadSymbolValue("rpc_call", &remote_msg); if (status != HEX_STAT_SUCCESS) { printf("HexagonWrapper::ReadSymbolValue(rpcmsg) failed: %d\n", status); return -1; } if (write_memory(remote_msg, &msg, 4) != 0) { return -1; } // The arguments are individual numbered variables. for (size_t i = 0; i < arguments.size(); i++) { HEX_4u_t remote_arg = 0; std::string rpc_arg = "rpc_arg" + std::to_string(i); status = sim->ReadSymbolValue(rpc_arg.c_str(), &remote_arg); if (status != HEX_STAT_SUCCESS) { printf("HexagonWrapper::ReadSymbolValue(%s) failed: %d\n", rpc_arg.c_str(), status); return -1; } if (write_memory(remote_arg, &arguments[i], 4) != 0) { return -1; } } HEX_4u_t remote_ret = 0; status = sim->ReadSymbolValue("rpc_ret", &remote_ret); if (status != HEX_STAT_SUCCESS) { printf("HexagonWrapper::ReadSymbolValue(rpc_ret) failed: %d\n", status); return -1; } // Get the remote address of the current func. There's a remote // pointer to it, so we need to walk through a few levels of // indirection. HEX_4u_t remote_profiler_current_func_addr_addr = 0; HEX_4u_t remote_profiler_current_func_addr = 0; status = sim->ReadSymbolValue("profiler_current_func_addr", &remote_profiler_current_func_addr_addr); if (status != HEX_STAT_SUCCESS) { printf("HexagonWrapper::ReadSymbolValue(profiler_current_func_addr) failed: %d\n", status); return -1; } if (read_memory(&remote_profiler_current_func_addr, remote_profiler_current_func_addr_addr, sizeof(HEX_4u_t))) { return -1; } HEXAPI_CoreState state; // If we are debugging using LLDB, then we cannot use sim->Step, but // we need to use sim->Run to allow LLDB to take over. if (msg == Message::Break || (debug_mode && (msg == Message::Run))) { // If we're trying to end the remote simulation, just run // until completion. HEX_4u_t result; state = sim->Run(&result); if (state != HEX_CORE_FINISHED) { printf("HexagonWrapper::Run failed: %d\n", state); return -1; } return 0; } else { // If we want to return and continue simulating, we execute // 1000 cycles at a time, until the remote indicates it has // completed handling the current message. do { HEX_4u_t cycles; state = sim->Step(1000, &cycles); if (read_memory(&msg, remote_msg, 4) != 0) { return -1; } if (msg == Message::None) { HEX_4u_t ret = 0; if (read_memory(&ret, remote_ret, 4)) { return -1; } return ret; } // Grab the remote profiler state in case we're profiling read_memory(&profiler_current_func, remote_profiler_current_func_addr, sizeof(int)); } while (state == HEX_CORE_SUCCESS); printf("HexagonWrapper::StepTime failed: %d\n", state); return -1; } }