void ThreadCommand::PopBuffer::Execute() { ThreadCommand* command = toCommand(); OVR_ASSERT(command); command->Execute(); if (NeedsWait()) GetEvent()->PulseEvent(); }
void ThreadCommand::PopBuffer::InitFromBuffer(void* data) { ThreadCommand* cmd = (ThreadCommand*)data; OVR_ASSERT(cmd->Size <= MaxSize); if (Size) Destruct<ThreadCommand>(toCommand()); Size = cmd->Size; memcpy(Buffer, (void*)cmd, Size); }
// robosolver <size> <pos> move <from> <direction> // robosolver <size> <pos> to <from> <to> // robosolver <size> <pos> find <color> // robosolver <size> <pos> solve <to> int main(int argc, const char** argv) { N = atoi(argv[1]); field f = parse(strdup(argv[2])); if (strcmp("move", argv[3]) == 0) { moveCommand(f, atoi(argv[4]), atoi(argv[5])); } else if (strcmp("to", argv[3]) == 0) { toCommand(f, atoi(argv[4]), atoi(argv[5])); } else if (strcmp("find", argv[3]) == 0) { findCommand(f, atoi(argv[4])); } else if (strcmp("solve", argv[3]) == 0) { solveCommand(f, atoi(argv[4])); } return 0; }
int main(int argc, char* argv[]) { if (argc < 2) { std::cout << "Usage cworker [command] [param1] [param2] ...." << std::endl; std::cout << "For a list of commands use the 'help' command" << std::endl; return 0; } switch (toCommand(std::string(argv[1]))) { case help: std::cout << "Commands:" << std::endl; std::cout << "help \n\t Print this message" << std::endl; std::cout << "database [gamma] \n\t Generates a precomputed edges database with a specific gamma" << std::endl; std::cout << "index [gamma] \n\t Generates a graph indexing file which is used to load the correct samples. Gamma can be adjusted, but must not be bigger than the one the database was generated with"<<std::endl; break; case database: if (argc == 3) { float gamma = atof(argv[2]); std::cout << "Generating database with gamma = " << gamma << std::endl; GenerateDatabase(gamma); } else { std::cout << "You must supply a gamma" << std::endl; } break; case index: if (argc == 3) { float gamma = atof(argv[2]); std::cout << "Generating index with gamma = " << gamma << std::endl; GenerateIndex(gamma); } else { std::cout << "You must supply a gamma" << std::endl; } break; break; default: std::cout << "Not a valid command" << std::endl; break; } }
ThreadCommand::PopBuffer::~PopBuffer() { if (Size) Destruct<ThreadCommand>(toCommand()); }