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

Set the thread name.

Parameters
[in]nmthe new name (NULL to unset)
Returns
*this
Exceptions
std::bad_alloc

Definition at line 138 of file thread.cpp.

References likely, m_name, and unlikely.

Referenced by operator=().

139 {
140  if ( unlikely(nm == NULL) ) {
141  delete[] m_name;
142  m_name = NULL;
143  return *this;
144  }
145 
146  u32 len = strlen(nm);
147  if ( likely(m_name == NULL || len > strlen(m_name)) ) {
148  delete[] m_name;
149  m_name = NULL;
150  m_name = new i8[len + 1];
151  }
152 
153  strcpy(m_name, nm);
154  return *this;
155 }
i8 * m_name
Thread name.
Definition: thread.hpp:33
char i8
8-bit signed integer
Definition: config.hpp:72
#define likely(expr)
Offer a hint (positive) to the pipeline branch predictor.
Definition: config.hpp:344
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 caller graph for this function: