| 308 | } |
| 309 | |
| 310 | int main(int argc, char** argv) |
| 311 | { |
| 312 | const int nthreads = std::max(argc > 1 ? atoi(argv[1]) : 1, 1); |
| 313 | const int iterations = std::max(argc > 2 ? atoi(argv[2]) : 1, 1); |
| 314 | s_enable_annotations = argc > 3 ? !!atoi(argv[3]) : true; |
| 315 | |
| 316 | for (int j = 0; j < iterations; ++j) |
| 317 | { |
| 318 | std::vector<Thread> T(nthreads); |
| 319 | smart_ptr<counter> p(new counter); |
| 320 | p->post_increment(); |
| 321 | for (std::vector<Thread>::iterator q = T.begin(); q != T.end(); q++) |
| 322 | q->Create(thread_func, new smart_ptr<counter>(p)); |
| 323 | { |
| 324 | // Avoid that counter.m_mutex introduces a false ordering on the |
| 325 | // counter.m_count accesses. |
| 326 | const timespec delay = { 0, 100 * 1000 * 1000 }; |
| 327 | nanosleep(&delay, 0); |
| 328 | } |
| 329 | p = NULL; |
| 330 | for (std::vector<Thread>::iterator q = T.begin(); q != T.end(); q++) |
| 331 | q->Join(); |
| 332 | } |
| 333 | std::cerr << "Done.\n"; |
| 334 | return 0; |
| 335 | } |
nothing calls this directly
no test coverage detected