| 13 | } |
| 14 | |
| 15 | int main(int argc, char* argv[]) |
| 16 | { |
| 17 | int ch, cocurrent = 1, count = 10, length = 1024; |
| 18 | bool keep_alive = false; |
| 19 | acl::string server_addr("127.0.0.1:8888"); |
| 20 | |
| 21 | // ��ʼ�� acl �� |
| 22 | acl::acl_cpp_init(); |
| 23 | |
| 24 | while ((ch = getopt(argc, argv, "hs:c:n:k")) > 0) |
| 25 | { |
| 26 | switch (ch) |
| 27 | { |
| 28 | case 'h': |
| 29 | usage(argv[0]); |
| 30 | return 0; |
| 31 | case 'c': |
| 32 | cocurrent = atoi(optarg); |
| 33 | break; |
| 34 | case 'n': |
| 35 | count = atoi(optarg); |
| 36 | break; |
| 37 | case 'k': |
| 38 | keep_alive = true; |
| 39 | break; |
| 40 | case 's': |
| 41 | server_addr = optarg; |
| 42 | break; |
| 43 | default: |
| 44 | break; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | struct timeval begin; |
| 49 | gettimeofday(&begin, NULL); |
| 50 | |
| 51 | std::list<thread_client*> threads; |
| 52 | |
| 53 | for (int i = 0; i < cocurrent; i++) |
| 54 | { |
| 55 | // �����߳ |
| 56 | thread_client* thread = new thread_client(server_addr, keep_alive, |
| 57 | count, length); |
| 58 | |
| 59 | // ���ô������߳�Ϊ�Ƿ���ģʽ���Ա���������Ե�� thread::wait |
| 60 | // �ȴ��߳̽��� |
| 61 | thread->set_detachable(false); |
| 62 | |
| 63 | // ���̷߳��ڶ���� |
| 64 | threads.push_back(thread); |
| 65 | |
| 66 | // �����߳ |
| 67 | thread->start(); |
| 68 | } |
| 69 | |
| 70 | std::list<thread_client*>::iterator it = threads.begin(); |
| 71 | for (; it != threads.end(); ++it) |
| 72 | { |
nothing calls this directly
no test coverage detected
searching dependent graphs…