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

Function test_thread_pool

lib_acl_cpp/samples/thread_pool/main.cpp:63–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61//////////////////////////////////////////////////////////////////////////
62
63static void test_thread_pool(int n)
64{
65 if (n == 0)
66 {
67 mythread_pool* threads = new mythread_pool;
68 threads->start();
69
70 mythread thread1, thread2;
71
72 threads->execute(&thread1);
73 threads->execute(&thread2);
74
75 // ��Ϊ thread1, thread2 �Ƕ�ջ���������Ա������
76 // threads->stop �ȴ����߳����н���
77 threads->stop();
78 delete threads;
79 }
80 else if (n == 1)
81 {
82 mythread_pool threads;
83 threads.start();
84
85 mythread *thread1 = new mythread, *thread2 = new mythread;
86 threads.execute(thread1);
87 threads.execute(thread2);
88
89 // Ϊ�˱�֤ threads1, thread2 ��̬�ڴ汻��ȷ�ͷţ�
90 // ������� threads.stop �ȴ����߳����н�������
91 // ���߳��н����ͷ�
92 threads.stop();
93
94 // �����߳����ͷŶ�̬����Ķ���
95 delete thread1;
96 delete thread2;
97 }
98 else if (n == 2)
99 {
100 mythread_pool threads;
101 threads.start();
102
103 mythread thread1, thread2;
104
105 threads.execute(&thread1);
106 threads.execute(&thread2);
107
108 // ��Ϊ thread1, thread2 �Ƕ�ջ���������Ա������
109 // threads->stop �ȴ����߳����н���
110 threads.stop();
111 }
112 else if (n == 3)
113 {
114 mythread_pool threads;
115 threads.start();
116
117 mythread *thread1 = new mythread(true);
118 mythread *thread2 = new mythread(true);
119
120 threads.execute(thread1);

Callers 1

mainFunction · 0.70

Calls 5

threads_countMethod · 0.80
startMethod · 0.45
executeMethod · 0.45
stopMethod · 0.45
task_qlenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…