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

Function thread_main

lib_acl_cpp/samples/connect_manager/main.cpp:105–145  ·  view source on GitHub ↗

���̴߳�������

Source from the content-addressed store, hash-verified

103
104// ���̴߳�������
105static void thread_main(void*)
106{
107 for (int i = 0; i < __loop_count; i++) {
108 connect_pool* pool = (connect_pool*) __conn_manager->peek();
109 if (pool == NULL) {
110 printf("\r\n>>>%lu(%d): peek pool failed<<<\r\n",
111 (unsigned long) acl_pthread_self(), __LINE__);
112 check_all_connections();
113 break;
114 }
115
116 // �������ӵij�ʱʱ�估����ʱʱ��
117 pool->set_timeout(2, 2);
118
119 // �����ӳ��л�ȡһ������
120 connect_client* conn = (connect_client*) pool->peek();
121 if (conn == NULL) {
122 printf("\r\n>>>%lu: peek connect failed from %s<<<\r\n",
123 (unsigned long) acl_pthread_self(),
124 pool->get_addr());
125 check_all_connections();
126 break;
127 }
128
129 // ��Ҫ�Ի�õ���������״̬��������ϴ�������̵���ʱ����
130 else {
131 conn->reset();
132 }
133
134 // ��ʼ�µ� HTTP �������
135 if (get(conn, i) == false) {
136 printf("one request failed, close connection\r\n");
137 // ����������Ҫ�ر�
138 pool->put(conn, false);
139 } else {
140 pool->put(conn, true);
141 }
142 }
143
144 printf(">>>>thread: %lu OVER<<<<\r\n", (unsigned long) acl_pthread_self());
145}
146
147static void run(int cocurrent, int delay)
148{

Callers

nothing calls this directly

Calls 8

acl_pthread_selfFunction · 0.85
check_all_connectionsFunction · 0.70
getFunction · 0.70
peekMethod · 0.45
set_timeoutMethod · 0.45
get_addrMethod · 0.45
resetMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…