| 50 | } |
| 51 | |
| 52 | int main(int argc, char* argv[]) |
| 53 | { |
| 54 | int ch, nthreads = 10; |
| 55 | |
| 56 | while ((ch = getopt(argc, argv, "ht:n:S")) > 0) |
| 57 | { |
| 58 | switch (ch) |
| 59 | { |
| 60 | case 'h': |
| 61 | usage(argv[0]); |
| 62 | return 0; |
| 63 | case 't': |
| 64 | nthreads = atoi(optarg); |
| 65 | break; |
| 66 | case 'n': |
| 67 | __nloop = atoi(optarg); |
| 68 | break; |
| 69 | case 'S': |
| 70 | __show = true; |
| 71 | break; |
| 72 | default: |
| 73 | break; |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | acl::log::stdout_open(true); |
| 78 | acl::event_mutex lock(true); |
| 79 | lock.lock(); |
| 80 | lock.lock(); |
| 81 | lock.unlock(); |
| 82 | lock.unlock(); |
| 83 | |
| 84 | printf("test ok, enter any key to continue ..."); |
| 85 | fflush(stdout); |
| 86 | getchar(); |
| 87 | |
| 88 | std::vector<acl::thread*> threads; |
| 89 | for (int i = 0; i < nthreads; i++) |
| 90 | { |
| 91 | acl::thread* thr = new mythread(lock); |
| 92 | threads.push_back(thr); |
| 93 | thr->start(); |
| 94 | } |
| 95 | |
| 96 | for (std::vector<acl::thread*>::iterator it = threads.begin(); |
| 97 | it != threads.end(); ++it) |
| 98 | { |
| 99 | (*it)->wait(); |
| 100 | delete *it; |
| 101 | } |
| 102 | |
| 103 | printf("\r\nAt last, count=%d\r\n", __count); |
| 104 | return 0; |
| 105 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…