| 57 | }; |
| 58 | |
| 59 | int main(void) |
| 60 | { |
| 61 | acl::thread_pool threads; |
| 62 | threads.set_limit(500); |
| 63 | threads.start(); |
| 64 | |
| 65 | int nconsumers = 10, max_loop = 1000000; |
| 66 | std::vector<acl::thread*> consumers; |
| 67 | for (int i = 0; i < nconsumers; i++) { |
| 68 | acl::thread* thr = new consumer(threads, max_loop); |
| 69 | consumers.push_back(thr); |
| 70 | thr->start(); |
| 71 | } |
| 72 | |
| 73 | for (std::vector<acl::thread*>::iterator it = consumers.begin(); |
| 74 | it != consumers.end(); ++it) { |
| 75 | (*it)->wait(); |
| 76 | delete *it; |
| 77 | } |
| 78 | |
| 79 | threads.stop(); |
| 80 | |
| 81 | printf("All over: count=%d\r\n", nconsumers * max_loop); |
| 82 | return 0; |
| 83 | } |