MCPcopy Create free account
hub / github.com/alibaba/PhotonLibOS / thread_create_ex

Method thread_create_ex

thread/thread-pool.cpp:33–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31 }
32
33 TPControl* ThreadPoolBase::thread_create_ex(thread_entry start, void* arg, bool joinable)
34 {
35 if (m_capacity == 0 || __should_bypass_threadpool()) {
36 auto th = photon::thread_create(start, arg, (uint64_t)m_reserved,
37 sizeof(TPControl));
38 auto pCtrl = photon::thread_reserved_space<TPControl>(th);
39 pCtrl->th = th;
40 /* Actually unused in `bypass_threadpool` condition
41 because all threadcreate work are forwarding to
42 `photon::thread_create`
43
44 // pCtrl->joinable = joinable;
45 // pCtrl->start = start;
46 // pCtrl->arg = arg;
47 */
48 if (joinable) {
49 photon::thread_enable_join(th);
50 }
51 return pCtrl;
52 }
53 auto pCtrl = B::get();
54 {
55 SCOPED_LOCK(pCtrl->m_mtx);
56 pCtrl->joinable = joinable;
57 pCtrl->joining = false;
58 pCtrl->start = start;
59 pCtrl->arg = arg;
60 pCtrl->cvar.notify_one();
61 }
62 return pCtrl;
63 }
64 bool ThreadPoolBase::wait_for_work(TPControl &ctrl)
65 {
66 SCOPED_LOCK(ctrl.m_mtx);

Callers 1

TESTFunction · 0.80

Calls 5

thread_createFunction · 0.85
thread_enable_joinFunction · 0.85
getFunction · 0.50
notify_oneMethod · 0.45

Tested by 1

TESTFunction · 0.64