libcsdbg  1.28
C++ exception (and generic) stack trace debug library
process & csdbg::process::cleanup_thread ( pthread_t  id)
virtual

Cleanup libcsdbg-related thread resources upon thread cancellation.

Parameters
[in]idthe thread ID
Returns
*this
Attention
This method should be called from thread cancellation handlers to release resources. If you don't cleanup the thread handle though it becomes useless when the actual thread has exited, it continues to occupy memory and will also inject junk, empty traces in dumps or in explicit trace requests
See Also
man pthread_cleanup_push, pthread_cleanup_pop

Definition at line 463 of file process.cpp.

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

464 {
465  util::lock();
466  for (u32 i = 0, sz = m_threads->size(); likely(i < sz); i++) {
467  thread *thr = m_threads->at(i);
468 
469  if ( unlikely(thr->is_current()) ) {
470  m_threads->remove(i);
471  util::unlock();
472  break;
473  }
474  }
475 
476  util::unlock();
477  return *this;
478 }
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: