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

Method thread_run

lib_acl_cpp/src/stdlib/thread.cpp:61–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61void* thread::thread_run(void* arg)
62{
63 thread* thr = (thread*) arg;
64#ifdef ACL_WINDOWS
65 thr->thread_id_ = GetCurrentThreadId();
66#elif defined(ACL_FREEBSD)
67#if defined(__FreeBSD__) && (__FreeBSD__ >= 9)
68 thr->thread_id_ = pthread_getthreadid_np();
69#else
70 thr->thread_id_ = (unsigned long) pthread_self();
71#endif
72#elif defined(ACL_MACOSX)
73 unsigned long long n;
74 (void) pthread_threadid_np(NULL, &n);
75 thr->thread_id_ = (unsigned long) n;
76#else
77 thr->thread_id_ = (unsigned long) pthread_self();
78#endif
79
80 // �Ƚ�֮ǰ push ����������ܻ�δ�������Ϣ�����������̶߳���
81 // �ٱ��ظ�ʹ�������߳�ʱ�������ʱ�ڴ�й¶
82 while (true) {
83 bool found;
84 thr->sync_->pop(0, &found);
85 if (!found) {
86 break;
87 }
88 }
89
90 thr->init();
91
92 thr->sync_->push(NULL);
93
94 // ����̴߳���ʱΪ����ģʽ���� run ����ʱ�û��п���
95 // ���̶߳��������ˣ����Բ����ٽ� thr->return_arg_ ����
96 // ��ֵ��������п��ܳ����ڴ�Ƿ�����
97 if (thr->detachable_) {
98 return thr->run();
99 }
100
101 thr->return_arg_ = thr->run();
102 return thr->return_arg_;
103}
104
105bool thread::start(bool sync /* = false */)
106{

Callers

nothing calls this directly

Calls 4

popMethod · 0.45
initMethod · 0.45
pushMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected