int main() { AFile_IOStream iosfile; AString str; while (AString::npos != iosfile.readLine(str)) { std::cout << "'" << str << "'=" << str.getHash() << "\t" << str.getHash(0xff) << "\t" << str.getHash(0xf) << std::endl; str.clear(); } }
int main() { CommonData data; AThreadPool threadpool(mythreadproc, 20, NULL, &data, callbackThreadPoolMonitor); threadpool.setTotalThreadCreationCount(30); threadpool.start(); AFile_IOStream io; AString str; while (!g_MonitorExited && AConstant::npos != io.readLine(str)) { if (str.equalsNoCase("exit")) break; AThread::sleep(1000); } threadpool.stop(); return 0; }
int main(int argc, char **argv) { bool bRun = true; u4 iteration = 0; AThread thread(threadProc); thread.setParameter((void *)&iteration); AString cmd; AFile_IOStream io; while (bRun) { std::cout << ">"; io.readLine(cmd); if (!cmd.compareNoCase("status")) { if (thread.isThreadActive()) { u4 id = thread.getId(); u4 iter = *(u4 *)thread.getParameter(); std::cout << "Thread active, id=" << id << " iteration=" << iter << std::endl; } else if (thread.wasStarted()) { u4 exitCode = thread.getExitCode(); u4 iter = *(u4 *)thread.getParameter(); std::cout << "Thread exited, return=" << exitCode << " iteration=" << iter << std::endl; } else { std::cout << "Thread has never started." << std::endl; } } else if (!cmd.compareNoCase("start")) { if (!thread.isThreadActive()) { thread.clearFlag(ATHREAD_STOP); thread.start(); } else { std::cout << "Thread already running." << std::endl; } } else if (!cmd.compareNoCase("pause")) { thread.setFlag(ATHREAD_PAUSE); } else if (!cmd.compareNoCase("resume")) { thread.clearFlag(ATHREAD_PAUSE); } else if (!cmd.compareNoCase("stop")) { if (thread.isThreadActive()) { thread.setFlag(ATHREAD_STOP); std::cout << "Trying to stop" << std::flush; while (thread.isThreadActive()) { AThread::sleep(100); std::cout << "." << std::flush; } std::cout << std::endl; } } else if (!cmd.compareNoCase("exit")) { if (thread.isThreadActive()) { thread.setFlag(ATHREAD_STOP); std::cout << "Trying to stop" << std::flush; while (thread.isThreadActive()) { AThread::sleep(100); std::cout << "." << std::flush; } std::cout << std::endl; } bRun = false; } cmd.clear(); } return 0; }
int main(int argc, char **argv) { if (argc < 2) { std::cout << "Usage: this [SQLite database URL]" << std::endl; std::cout << "e.g. this sqlite://q:/mydata.db" << std::endl; return -1; } AUrl url(argv[1]); ASQLiteServer db(url); AString error; if (!db.init(error)) { std::cerr << error << std::endl; return -1; } AString input; AFile_IOStream iof; std::cout << "\r\nsqlite [?=help]>" << std::flush; while(AString::npos != iof.readLine(input)) { if (input.equals("createAOSTables")) { if (AString::npos == createAOSTables(db, error)) std::cerr << error << std::endl; else std::cout << "AOS tables created." << std::endl; } else if (input.equals("?")) { std::cout << "Enter SQL query or use one of the following built in functions:\r\n"; std::cout << " createAOSTables - create databases used by base AOS server modules\r\n"; std::cout << std::endl; } else if (input.equals("exit")) { return 0; } else { AResultSet rs; u4 rows = db.executeSQL(input, rs, error); if (AString::npos == rows) { std::cerr << error << std::endl; error.clear(); } else { std::cout << "Success, rows affected=" << rows << std::endl; ARope rope; rs.emit(rope); std::cout << rope << std::endl; } } input.clear(); std::cout << "\r\nsqlite>" << std::flush; } return 0; }