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

Get a thread by ID.

[in]idthe thread ID
the csdbg::thread object that tracks the actual thread (with the given ID) or NULL if no such thread is found

Definition at line 376 of file process.cpp.

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

Referenced by csdbg::tracer::dump(), and csdbg::tracer::trace().

377 {
378  util::lock();
379  for (u32 i = 0, sz = m_threads->size(); likely(i < sz); i++) {
380  thread *thr = m_threads->at(i);
382  if ( unlikely(thr->is_current()) ) {
383  util::unlock();
384  return thr;
385  }
386  }
388  util::unlock();
389  return NULL;
390 }
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

+ Here is the call graph for this function:

+ Here is the caller graph for this function: