bool ConsoleBluetoothStarter::startBluetooth(const TrkDevicePtr &trkDevice, QObject *listenerParent, const QString &device, int attempts, QString *errorMessage) { // Set up a console starter to print to stdout. ConsoleBluetoothStarter starter(trkDevice, listenerParent); starter.setDevice(device); starter.setAttempts(attempts); switch (starter.start()) { case Started: break; case ConnectionSucceeded: return true; case StartError: *errorMessage = starter.errorString(); return false; } // Run the starter with an event loop. @ToDo: Implement // some asynchronous keypress read to cancel. QEventLoop eventLoop; connect(&starter, SIGNAL(connected()), &eventLoop, SLOT(quit())); connect(&starter, SIGNAL(timeout()), &eventLoop, SLOT(quit())); eventLoop.exec(QEventLoop::ExcludeUserInputEvents); if (starter.state() != AbstractBluetoothStarter::Connected) { *errorMessage = starter.errorString(); return false; } return true; }
int XHServiceBasePrivate::run(bool asService, const std::vector<std::string> &argList) { int argc = argList.size(); std::vector<char *> argv(argc); std::vector<std::string> argvData; for (int i = 0; i < argc; ++i) argvData.push_back(argList[i]); for (int i = 0; i < argc; ++i){ char* c; const int len = argvData[i].length(); c = new char[len + 1]; strcpy(c, argvData[i].c_str()); argv[i] = c; } if (asService && !sysInit()) return -1; q_ptr->createApplication(argc,argv.data()); if (asService) sysSetPath(); XHServiceStarter starter(this); starter.slotStart(); // TODO int res = q_ptr->executeApplication(); if (asService) sysCleanup(); return res; }
int _tmain(int argc, _TCHAR* argv[]) { std::string name_input; std::cout << "Welcome to SALTYFIGHT V.0.0\nPlease enter a character name to get started." << std::endl; std::getline(std::cin, name_input); Character starter(name_input); std::cout << "You entered: " << starter.getName() << std::endl; std::cout << "Your class is : " << starter.getCharClass() << std::endl; //Here we should hand off the execution to a menu thread system("pause"); return 0; }
void Aggregate::worker() try { //fancyprint("STARTER",NOTIFY); starter(); //fancyprint("SPLITTER",NOTIFY); splitter(); //fancyprint("JOIN ALL",NOTIFY); joinChunks(); //fancyprint("MERGER",NOTIFY); merger(); } catch ( ex::Error e ) { m_failed = true; //fancyprint(e.what(),ERROR); std::cout << e.what() << std::endl; }
int& NextStep:: triggerCall( int& dummy,int timeCurrent ) { sotDEBUGIN(45); switch( state ) { case STATE_STOPED: break; case STATE_STARTED: { int nextIntoductionTime = timeLastIntroduction+period; if( nextIntoductionTime<=timeCurrent ) { nextStep( timeCurrent ); if( NULL!=verbose ) { FootPrint & lastStep = footPrintList.back(); (*verbose) << "<T=" << timeCurrent << "> Introduced a new step: "; switch( lastStep.contact ) { case CONTACT_LEFT_FOOT: (*verbose) << "LF " ; break; case CONTACT_RIGHT_FOOT: (*verbose) << "RF " ; break; } (*verbose) << lastStep.x << "," << lastStep.y << "," << lastStep.theta << std::endl; } introductionCallBack( timeCurrent ); timeLastIntroduction=timeCurrent; } break; } case STATE_STARTING: { starter( timeCurrent ); break; } case STATE_STOPING: { stoper( timeCurrent ); break; } }; sotDEBUGOUT(45); return dummy; }
int main( int argc, char** argv ) { (void) argc; (void) argv; thread_free = get_nprocs_conf(); printf("%d\n",thread_free ); InitFic(); starter(); moyenneCSV(); return 0; }
void MemChecker::start() { if (!needMemCheck()) { return; } ModuleLoader *loader = testcase->getLoader(); typedef void (*start_t)(mem_checker::Reporter *, mem_checker::Reporter *); start_t starter = (start_t)loader->findSymbol("startMemChecker"); TestFixture *fixture = testcase->getFixture(); info = mem_checker::createReporter(InfoReporter(fixture)); failure = mem_checker::createReporter(FailureReporter(fixture)); // Note: Reporter is new in runner.exe, and used in .dll. is this ok? starter(info, failure); }
/* Run the above test twice, in two separate threads. The second run ought to * call retry twice, because its instance number will be less than the process * instance number. */ int main() { struct retry expected; const char *term = "exit\n"; pthread_t thread; struct attendant__initializer initializer; printf("1..14\n"); initializer.starter = starter; initializer.connector = connector; strcat(getcwd(initializer.relay, sizeof(initializer.relay)), "/relay"); initializer.canary = 31; /* Initialize the attendant. */ attendant.initialize(&initializer); /* Start the server. */ starter(0); attendant.ready(); expected.name = "first"; expected.count = 1; retry(&expected); expected.name = "second"; expected.count++; pthread_create(&thread, NULL, retry, &expected); pthread_join(thread, NULL); /* Shutdown the server. */ attendant.shutdown(); send(term); /* Wait for shutdown. */ ok(attendant.done(1000), "done"); /* Destroy the attendant. */ attendant.destroy(); /* We're good. */ return EXIT_SUCCESS; }
bool SPxSolver::writeState( const char* filename, const NameSet* rowNames, const NameSet* colNames ) const { METHOD( "SPxSolver::writeState()" ); std::string ofname; std::ofstream ofs; // write parameter settings ofname = std::string(filename) + ".set"; ofs.open(ofname.c_str()); if (!ofs) return false; std::stringstream table, commandline; table << "Delta = " << std::setw(8) << delta() << std::endl << "Epsilon Zero = " << std::setw(8) << Param::epsilon() << std::endl << "Epsilon Factor = " << std::setw(8) << Param::epsilonFactorization() << std::endl << "Epsilon Update = " << std::setw(8) << Param::epsilonUpdate() << std::endl << "Verbosity = " << std::setw(8) << Param::verbose() << std::endl << std::endl << "Algorithm = " << (type() == SPxSolver::ENTER ? "Entering" : "Leaving") << std::endl << "Representation = " << (rep() == SPxSolver::ROW ? "Row" : "Column") << std::endl << "Update = " << slinSolver()->getName() << std::endl << "Pricer = " << pricer()->getName() #ifdef PARTIAL_PRICING << " (partial, size = " << MAX_PRICING_CANDIDATES << ")" #endif << std::endl << "Starter = " << ((starter() == 0) ? "no" : starter()->getName()) << std::endl << "Ratiotest = " << ratiotester()->getName() << std::endl << std::endl; commandline << "bin/soplex -g0 -s0" << " -f" << feastol() << " -o" << opttol() << (type() == SPxSolver::ENTER ? " -e" : "") << (rep() == SPxSolver::ROW ? " -r" : "") << (!strcmp(slinSolver()->getName(), "SLU-Eta") ? " -i" : ""); if (!strcmp(pricer()->getName(), "Dantzig")) commandline << " -p0"; else if (!strcmp(pricer()->getName(), "ParMult")) commandline << " -p1"; else if (!strcmp(pricer()->getName(), "Devex")) commandline << " -p2"; else if (!strcmp(pricer()->getName(), "Hybrid")) commandline << " -p3"; else if (!strcmp(pricer()->getName(), "Steep")) commandline << " -p4"; else if (!strcmp(pricer()->getName(), "Weight")) commandline << " -p5"; else if (!strcmp(pricer()->getName(), "SteepEx")) commandline << " -p6"; if (starter() != 0) { if (!strcmp(starter()->getName(), "Weight")) commandline << " -s1"; else if (!strcmp(starter()->getName(), "Sum")) commandline << " -s2"; else if (!strcmp(starter()->getName(), "Vector")) commandline << " -s3"; } if (!strcmp(ratiotester()->getName(), "Default")) commandline << " -t0"; else if (!strcmp(ratiotester()->getName(), "Harris")) commandline << " -t1"; else if (!strcmp(ratiotester()->getName(), "Fast")) commandline << " -t2"; else if (!strcmp(ratiotester()->getName(), "Bound Flipping")) commandline << " -t3"; commandline << " -br " << filename << ".mps " << filename << ".bas"; ofs << "SoPlex Parameters:\n\n" << table.str() << "Command line > " << commandline.str(); ofs.close(); // write LP ofname = std::string(filename) + ".mps"; ofs.open(ofname.c_str()); if (!ofs) return false; writeMPS(ofs, rowNames, colNames, NULL); ofs.close(); // write basis ofname = std::string(filename) + ".bas"; return writeBasisFile(ofname.c_str(), rowNames, colNames); }
NPError OSCALL NP_Initialize(NPNetscapeFuncs *browser) { const char *home; char logfile[PATH_MAX]; const char* dir; Dl_info library; struct attendant__initializer initializer; say("NP_Initialize"); /* Copy the browser NPAPI functions into our library. */ npn_get_url = browser->geturl; npn_post_url = browser->posturl; npn_request_read = browser->requestread; npn_new_stream = browser->newstream; npn_write = browser->write; npn_destroy_stream = browser->destroystream; npn_status = browser->status; npn_user_agent = browser->uagent; npn_mem_alloc = browser->memalloc; npn_mem_free = browser->memfree; npn_mem_flush = browser->memflush; npn_reload_plugins = browser->reloadplugins; npn_get_java_env = browser->getJavaEnv; npn_get_java_peer = browser->getJavaPeer; npn_get_url_notify = browser->geturlnotify; npn_post_url_notify = browser->posturlnotify; npn_get_value = browser->getvalue; npn_set_value = browser->setvalue; npn_invalidate_rect = browser->invalidaterect; npn_invalidate_region = browser->invalidateregion; npn_force_redraw = browser->forceredraw; npn_get_string_identifier = browser->getstringidentifier; npn_get_string_identifiers = browser->getstringidentifiers; npn_get_int_identifier = browser->getintidentifier; npn_identifier_is_string = browser->identifierisstring; npn_utf8_from_indentifier = browser->utf8fromidentifier; npn_int_from_identifier = browser->intfromidentifier; npn_create_object = browser->createobject; npn_retain_object = browser->retainobject; npn_release_object = browser->releaseobject; npn_invoke = browser->invoke; npn_invoke_default = browser->invokeDefault; npn_evaluate = browser->evaluate; npn_get_property = browser->getproperty; npn_set_property = browser->setproperty; npn_remove_property = browser->removeproperty; npn_has_property = browser->hasproperty; npn_has_method = browser->hasmethod; npn_release_variant_value = browser->releasevariantvalue; npn_set_exception = browser->setexception; npn_push_popups_enabled_state = browser->pushpopupsenabledstate; npn_pop_popups_enabled_state = browser->poppopupsenabledstate; npn_enumerate = browser->enumerate; npn_plugin_thread_async_call = browser->pluginthreadasynccall; npn_construct = browser->construct; npn_get_value_for_url = browser->getvalueforurl; npn_set_value_for_url = browser->setvalueforurl; npn_get_authentication_info = browser->getauthenticationinfo; npn_schedule_timer = browser->scheduletimer; npn_unschedule_timer = browser->unscheduletimer; npn_pop_up_context_menu = browser->popupcontextmenu; npn_convert_point = browser->convertpoint; npn_handle_event = browser->handleevent; npn_unfocus_instance = browser->unfocusinstance; npn_url_redirect_response = browser->urlredirectresponse; /* Create our mutex and signaling device. */ (void) pthread_mutex_init(&plugin.mutex, NULL); (void) pthread_cond_init(&plugin.cond, NULL); dladdr(NP_Initialize, &library); dir = library.dli_fname + strlen(library.dli_fname); while (*dir != '/') { dir--; } strncat(plugin.node, library.dli_fname, dir - library.dli_fname); strcat(plugin.node, "/node"); chmod(plugin.node, 0755); memset(&initializer, 0, sizeof(struct attendant__initializer)); strncat(initializer.relay, library.dli_fname, dir - library.dli_fname); strcat(initializer.relay, "/relay"); chmod(initializer.relay, 0755); strncat(plugin.monitor, library.dli_fname, dir - library.dli_fname); strcat(plugin.monitor, "/monitor.js"); initializer.starter = starter; initializer.connector = connector; initializer.canary = 31; attendant.initialize(&initializer); starter(0, -1); say("node: %s", plugin.node); say("relay: %s", initializer.relay); plugin.curl = curl_easy_init(); return NPERR_NO_ERROR; }
int content_process_main(int argc, char* argv[]) { // Check for the absolute minimum number of args we need to move // forward here. We expect the last arg to be the child process type. if (argc < 1) { return 3; } bool isNuwa = false; for (int i = 1; i < argc; i++) { isNuwa |= strcmp(argv[i], "-nuwa") == 0; } XREChildData childData; #if defined(XP_WIN) && defined(MOZ_SANDBOX) if (IsSandboxedProcess()) { childData.sandboxTargetServices = mozilla::sandboxing::GetInitializedTargetServices(); if (!childData.sandboxTargetServices) { return 1; } childData.ProvideLogFunction = mozilla::sandboxing::ProvideLogFunction; } #endif XRE_SetProcessType(argv[--argc]); #ifdef MOZ_NUWA_PROCESS if (isNuwa) { PrepareNuwaProcess(); } #endif #if defined(XP_LINUX) && defined(MOZ_SANDBOX) // This has to happen while we're still single-threaded, and on // B2G that means before the Android Binder library is // initialized. Additional special handling is needed for Nuwa: // the Nuwa process itself needs to be unsandboxed, and the same // single-threadedness condition applies to its children; see also // AfterNuwaFork(). mozilla::SandboxEarlyInit(XRE_GetProcessType(), isNuwa); #endif #ifdef MOZ_WIDGET_GONK // This creates a ThreadPool for binder ipc. A ThreadPool is necessary to // receive binder calls, though not necessary to send binder calls. // ProcessState::Self() also needs to be called once on the main thread to // register the main thread with the binder driver. #ifdef MOZ_NUWA_PROCESS if (!isNuwa) { InitializeBinder(nullptr); } else { NuwaAddFinalConstructor(&InitializeBinder, nullptr); } #else InitializeBinder(nullptr); #endif #endif #ifdef XP_WIN // For plugins, this is done in PluginProcessChild::Init, as we need to // avoid it for unsupported plugins. See PluginProcessChild::Init for // the details. if (XRE_GetProcessType() != GeckoProcessType_Plugin) { mozilla::SanitizeEnvironmentVariables(); SetDllDirectoryW(L""); } #endif #if !defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_GONK) && defined(MOZ_PLUGIN_CONTAINER) // On desktop, the GMPLoader lives in plugin-container, so that its // code can be covered by an EME/GMP vendor's voucher. nsAutoPtr<mozilla::gmp::SandboxStarter> starter(MakeSandboxStarter()); if (XRE_GetProcessType() == GeckoProcessType_GMPlugin) { childData.gmpLoader = mozilla::gmp::CreateGMPLoader(starter); } #endif nsresult rv = XRE_InitChildProcess(argc, argv, &childData); NS_ENSURE_SUCCESS(rv, 1); return 0; }
int content_process_main(int argc, char* argv[]) { // Check for the absolute minimum number of args we need to move // forward here. We expect the last arg to be the child process type. if (argc < 1) { return 3; } XRE_SetProcessType(argv[--argc]); bool isNuwa = false; for (int i = 1; i < argc; i++) { isNuwa |= strcmp(argv[i], "-nuwa") == 0; #if defined(XP_WIN) && defined(MOZ_SANDBOX) gIsSandboxEnabled |= strcmp(argv[i], "-sandbox") == 0; #endif } #ifdef MOZ_NUWA_PROCESS if (isNuwa) { PrepareNuwaProcess(); } #endif #ifdef MOZ_WIDGET_GONK // This creates a ThreadPool for binder ipc. A ThreadPool is necessary to // receive binder calls, though not necessary to send binder calls. // ProcessState::Self() also needs to be called once on the main thread to // register the main thread with the binder driver. #ifdef MOZ_NUWA_PROCESS if (!isNuwa) { InitializeBinder(nullptr); } else { NuwaAddFinalConstructor(&InitializeBinder, nullptr); } #else InitializeBinder(nullptr); #endif #endif #ifdef XP_WIN // For plugins, this is done in PluginProcessChild::Init, as we need to // avoid it for unsupported plugins. See PluginProcessChild::Init for // the details. if (XRE_GetProcessType() != GeckoProcessType_Plugin) { mozilla::SanitizeEnvironmentVariables(); SetDllDirectory(L""); } #ifdef MOZ_SANDBOX if (gIsSandboxEnabled) { sandbox::TargetServices* target_service = sandbox::SandboxFactory::GetTargetServices(); if (!target_service) { return 1; } sandbox::ResultCode result = target_service->Init(); if (result != sandbox::SBOX_ALL_OK) { return 2; } mozilla::SandboxTarget::Instance()->SetStartSandboxCallback(StartSandboxCallback); #if defined(MOZ_CONTENT_SANDBOX) mozilla::warnonlysandbox::PrepareForInit(); #endif } #endif #endif nsAutoPtr<mozilla::gmp::GMPLoader> loader; #if !defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_GONK) // On desktop, the GMPLoader lives in plugin-container, so that its // code can be covered by an EME/GMP vendor's voucher. nsAutoPtr<mozilla::gmp::SandboxStarter> starter(MakeSandboxStarter()); if (XRE_GetProcessType() == GeckoProcessType_GMPlugin) { loader = mozilla::gmp::CreateGMPLoader(starter); } #endif nsresult rv = XRE_InitChildProcess(argc, argv, loader); NS_ENSURE_SUCCESS(rv, 1); return 0; }
AsyncProcessGroup::Result AsyncProcessGroup::execute(const Task &task) { async_process_group_detail::ProcessGroupStarter starter(task); starter.executionLoop(); return starter.result(); }