void TaskScheduler::Worker() { do { proc_(arg_); } while (!quit_event_->TimedWait(interval_)); }
int BuiltInProc::call(struct Jim_Interp * interp, int argc, Jim_Obj * const * argv) { // Check for the help command if (argc == 2 && Jim_CompareStringImmediate(interp, argv[1], "-help")) { Jim_SetResult(interp, Jim_NewEmptyStringObj(interp)); Jim_AppendStrings(interp, Jim_GetResult(interp), "Usage: \"", Jim_String(argv[0]), NULL); if (strlen(args_) > 0) Jim_AppendStrings(interp, Jim_GetResult(interp), " ", args_, NULL); Jim_AppendStrings(interp, Jim_GetResult(interp), "\""); if (strlen(desc_) > 0) Jim_AppendStrings(interp, Jim_GetResult(interp), " ", desc_, NULL); return JIM_OK; } return proc_(interp, argc, argv); }
int BuiltInSubProc::call(struct Jim_Interp * interp, int argc, Jim_Obj * const * argv) { bool help = false; const char * cmdName = Jim_String(argv[0]); if (argc < 2) { Jim_SetResult(interp, Jim_NewEmptyStringObj(interp)); Jim_AppendStrings(interp, Jim_GetResult(interp), "wrong # args: should be \"", cmdName, " command ...\"\n", NULL); Jim_AppendStrings(interp, Jim_GetResult(interp), "Use \"", cmdName, " -help ?command?\" for help about the command", NULL); return JIM_ERR; } Jim_Obj * cmd = argv[1]; // Check for the help command if (Jim_CompareStringImmediate(interp, cmd, "-help")) { if (argc == 2) { showCommandUsage(interp, argc, argv, subCommands_); return JIM_OK; } help = true; cmd = argv[2]; } // Check for special builtin '-commands' command first if (Jim_CompareStringImmediate(interp, cmd, "-commands")) { /* Build the result here */ Jim_SetResult(interp, Jim_NewEmptyStringObj(interp)); addSubCommands(interp, subCommands_, " "); return JIM_OK; } for (int i = 0; i < subCommands_.size() / 3; ++i) { if (Jim_CompareStringImmediate(interp, cmd, subCommands_[i * 3])) { if (help) { Jim_SetResult(interp, Jim_NewEmptyStringObj(interp)); Jim_AppendStrings(interp, Jim_GetResult(interp), "Usage: \"", cmdName, " ", subCommands_[i * 3], NULL); if (strlen(subCommands_[i * 3 + 1]) > 0) Jim_AppendStrings(interp, Jim_GetResult(interp), " ", subCommands_[i * 3 + 1], NULL); Jim_AppendStrings(interp, Jim_GetResult(interp), "\""); if (strlen(subCommands_[i * 3 + 2]) > 0) Jim_AppendStrings(interp, Jim_GetResult(interp), " ", subCommands_[i * 3 + 2], NULL); return JIM_OK; } else { return proc_(interp, i, argc - 2, argv + 2); } } } Jim_SetResult(interp, Jim_NewEmptyStringObj(interp)); Jim_AppendStrings(interp, Jim_GetResult(interp), cmdName, ", unknown command \"", Jim_String(cmd), "\" should be one of: ", NULL); addSubCommands(interp, subCommands_, ", "); return JIM_ERR; }