| 261 | } |
| 262 | |
| 263 | int main(int argc, char* argv[]) { |
| 264 | const char* dbpath = "./db"; |
| 265 | int ch, max = 1000, nthread = 1; |
| 266 | acl::string action("get"); |
| 267 | |
| 268 | while ((ch = getopt(argc, argv, "hn:a:c:i:")) > 0) { |
| 269 | switch (ch) { |
| 270 | case 'h': |
| 271 | usage(argv[0]); |
| 272 | return 0; |
| 273 | case 'n': |
| 274 | max = atoi(optarg); |
| 275 | break; |
| 276 | case 'a': |
| 277 | action = optarg; |
| 278 | break; |
| 279 | case 'c': |
| 280 | nthread = atoi(optarg); |
| 281 | break; |
| 282 | case 'i': |
| 283 | __inter = atoi(optarg); |
| 284 | break; |
| 285 | default: |
| 286 | break; |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | acl::string path; |
| 291 | path << dbpath; |
| 292 | wdb db(path); |
| 293 | if (!db.open()) { |
| 294 | printf("open db(%s) error\r\n", dbpath); |
| 295 | return 1; |
| 296 | } |
| 297 | |
| 298 | std::vector<acl::thread*> threads; |
| 299 | for (int i = 0; i < nthread; i++) { |
| 300 | acl::thread* thr = new db_thread(i, db, action, max); |
| 301 | threads.push_back(thr); |
| 302 | thr->start(); |
| 303 | } |
| 304 | |
| 305 | for (std::vector<acl::thread*>::iterator it = threads.begin(); |
| 306 | it != threads.end(); ++it) { |
| 307 | (*it)->wait(); |
| 308 | delete *it; |
| 309 | } |
| 310 | |
| 311 | return 0; |
| 312 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…