libcsdbg  1.28
C++ exception (and generic) stack trace debug library
thread * csdbg::process::get_thread ( const i8 nm) const
virtual

Get a thread by name.

Parameters
[in]nmthe name
Returns
the csdbg::thread object that tracks the actual thread (with the given name) or NULL if no such thread is found

Definition at line 402 of file process.cpp.

References __D_ASSERT, likely, csdbg::util::lock(), m_threads, csdbg::thread::name(), unlikely, and csdbg::util::unlock().

403 {
404  __D_ASSERT(nm != NULL);
405  if ( unlikely(nm == NULL) )
406  return NULL;
407 
408  util::lock();
409  for (u32 i = 0, sz = m_threads->size(); likely(i < sz); i++) {
410  thread *thr = m_threads->at(i);
411 
412  if ( unlikely(strcmp(thr->name(), nm) == 0) ) {
413  util::unlock();
414  return thr;
415  }
416  }
417 
418  util::unlock();
419  return NULL;
420 }
chain< thread > * m_threads
Instrumented thread list.
Definition: process.hpp:37
#define likely(expr)
Offer a hint (positive) to the pipeline branch predictor.
Definition: config.hpp:344
static void lock()
Lock the global access mutex.
Definition: util.cpp:397
static void unlock()
Unlock the global access mutex.
Definition: util.cpp:406
unsigned int u32
32-bit unsigned integer
Definition: config.hpp:102
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor.
Definition: config.hpp:349
#define __D_ASSERT(x)
Assertion macro.
Definition: config.hpp:268

+ Here is the call graph for this function: