| 189 | } |
| 190 | |
| 191 | int main(int argc acl_unused, char *argv[] acl_unused) |
| 192 | { |
| 193 | acl_pthread_pool_t *thr_pool; |
| 194 | int max_threads = 20; /* ��ಢ��20���߳� */ |
| 195 | int idle_timeout = 10; /* ÿ�������߳̿���10����Զ��˳� */ |
| 196 | static __thread ACL_VSTRING *buf = NULL; |
| 197 | |
| 198 | if (1) { |
| 199 | test_thread_pool(); |
| 200 | exit (0); |
| 201 | } |
| 202 | |
| 203 | buf = acl_vstring_alloc(256); |
| 204 | acl_vstring_sprintf(buf, "in main thread, id=%u", |
| 205 | (unsigned int) acl_pthread_self()); |
| 206 | acl_pthread_atexit_add(buf, main_thread_atexit); |
| 207 | |
| 208 | |
| 209 | thr_pool = thr_pool_create(max_threads, idle_timeout); |
| 210 | run_thread_pool(thr_pool); |
| 211 | |
| 212 | if (0) { |
| 213 | /* ����������� acl_pthread_pool_destroy�������ڵ������̳߳����ٺ����� |
| 214 | * ���̱߳�����֪ͨ�����߳��˳������п����̲߳��صȴ����г�ʱʱ�����˳�, |
| 215 | */ |
| 216 | printf("> wait all threads to be idle and free thread pool\r\n"); |
| 217 | /* ���������̳߳� */ |
| 218 | acl_pthread_pool_destroy(thr_pool); |
| 219 | } else { |
| 220 | /* ��Ϊ���������� acl_pthread_pool_destroy���������п����̶߳��ǵ����� |
| 221 | * ��ʱʱ�䵽�����˳� |
| 222 | */ |
| 223 | while (1) { |
| 224 | int ret; |
| 225 | |
| 226 | ret = acl_pthread_pool_size(thr_pool); |
| 227 | if (ret == 0) |
| 228 | break; |
| 229 | printf("> current threads in thread pool is: %d\r\n", ret); |
| 230 | sleep(1); |
| 231 | } |
| 232 | /* �̳߳��еĹ����߳���Ϊ0ʱ�����̳߳� */ |
| 233 | printf("> all worker thread exit now\r\n"); |
| 234 | acl_pthread_pool_destroy(thr_pool); |
| 235 | } |
| 236 | |
| 237 | /* ���̵߳ȴ��û����ն����������ַ����˳� */ |
| 238 | printf("> enter any key to exit\r\n"); |
| 239 | getchar(); |
| 240 | |
| 241 | return (0); |
| 242 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…