MCPcopy Create free account
hub / github.com/acl-dev/acl / main

Function main

lib_acl_cpp/samples/thread_client/main.cpp:15–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13}
14
15int 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 {

Callers

nothing calls this directly

Calls 11

acl_cpp_initFunction · 0.85
beginMethod · 0.80
thread_idMethod · 0.80
usageFunction · 0.70
getoptFunction · 0.50
gettimeofdayFunction · 0.50
stamp_subFunction · 0.50
push_backMethod · 0.45
startMethod · 0.45
endMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…