MCPcopy Create free account
hub / github.com/apache/singa / GetThreadCount

Function GetThreadCount

test/gtest/gtest-all.cc:8299–8314  ·  view source on GitHub ↗

Returns the number of threads running in the process, or 0 to indicate that we cannot detect it.

Source from the content-addressed store, hash-verified

8297// Returns the number of threads running in the process, or 0 to indicate that
8298// we cannot detect it.
8299size_t GetThreadCount() {
8300 const task_t task = mach_task_self();
8301 mach_msg_type_number_t thread_count;
8302 thread_act_array_t thread_list;
8303 const kern_return_t status = task_threads(task, &thread_list, &thread_count);
8304 if (status == KERN_SUCCESS) {
8305 // task_threads allocates resources in thread_list and we need to free them
8306 // to avoid leaks.
8307 vm_deallocate(task,
8308 reinterpret_cast<vm_address_t>(thread_list),
8309 sizeof(thread_t) * thread_count);
8310 return static_cast<size_t>(thread_count);
8311 } else {
8312 return 0;
8313 }
8314}
8315
8316#elif GTEST_OS_QNX
8317

Callers 1

AssumeRoleMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected