mirror of
https://github.com/introlab/rtabmap_ros.git
synced 2026-10-04 00:37:46 +08:00
Added printThreadId option in ULogger
This commit is contained in:
@@ -298,6 +298,13 @@ public:
|
||||
static void setPrintWhere(bool printWhere) {printWhere_ = printWhere;}
|
||||
static bool isPrintWhere() {return printWhere_;}
|
||||
|
||||
/**
|
||||
* Print thread ID: default false.
|
||||
* @param printThreadId true to print where, otherwise set to false.
|
||||
*/
|
||||
static void setPrintThreadId(bool printThreadId) {printThreadID_ = printThreadId;}
|
||||
static bool isPrintThreadId() {return printThreadID_;}
|
||||
|
||||
/**
|
||||
* Print the full path: default true. ULogger::setPrintWhere() must be true to have path printed.
|
||||
* @param printWhereFullPath true to print the full path, otherwise set to false.
|
||||
@@ -507,6 +514,12 @@ private:
|
||||
*/
|
||||
static bool printWhereFullPath_;
|
||||
|
||||
/*
|
||||
* If the logger prints the thread ID.
|
||||
* Default is false.
|
||||
*/
|
||||
static bool printThreadID_;
|
||||
|
||||
/*
|
||||
* If the logger limit the size of the "where" path to
|
||||
* characters. If the path is over 8 characters, a "~"
|
||||
|
||||
@@ -91,6 +91,10 @@ public:
|
||||
*/
|
||||
enum Priority{kPLow, kPBelowNormal, kPNormal, kPAboveNormal, kPRealTime};
|
||||
|
||||
public:
|
||||
//return caller thread id
|
||||
static unsigned long currentThreadId() {return (unsigned long)UThreadC<void>::Self();}
|
||||
|
||||
public:
|
||||
/**
|
||||
* The constructor.
|
||||
@@ -165,7 +169,7 @@ public:
|
||||
bool isKilled() const;
|
||||
|
||||
Handle getThreadHandle() const {return handle_;}
|
||||
|
||||
unsigned long getThreadId() const {return threadId_;}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -248,18 +252,14 @@ private:
|
||||
|
||||
private:
|
||||
void operator=(UThread & t) {}
|
||||
UThread( const UThread & t ) {}
|
||||
UThread( const UThread & t ) : state_(kSIdle) {}
|
||||
|
||||
private:
|
||||
enum State{kSIdle, kSCreating, kSRunning, kSKilled}; /* Enum of states. */
|
||||
State state_; /* The thread state. */
|
||||
Priority priority_; /* The thread priority. */
|
||||
Handle handle_; /* The thread handle. */
|
||||
#ifdef _WIN32
|
||||
int threadId_; /* The thread id. */
|
||||
#else
|
||||
unsigned long threadId_; /* The thread id. */
|
||||
#endif
|
||||
int cpuAffinity_; /* The cpu affinity. */
|
||||
UMutex killSafelyMutex_; /* Mutex used to protect the kill() method. */
|
||||
UMutex runningMutex_; /* Mutex used to notify the join method when the thread has finished. */
|
||||
|
||||
@@ -321,7 +321,7 @@ class UTILITE_EXP UThreadC<void>
|
||||
}
|
||||
|
||||
int Create(
|
||||
int & ThreadId,
|
||||
unsigned long & ThreadId,
|
||||
Handle * const & H = 0,
|
||||
const bool & CreateDetached = false,
|
||||
const unsigned int & StackSize = 0,
|
||||
@@ -330,7 +330,9 @@ class UTILITE_EXP UThreadC<void>
|
||||
) const
|
||||
{
|
||||
*H = InvalidHandle;
|
||||
*H = CREATE_THREAD2(StackSize,ThreadMainHandler,this, (LPDWORD)&ThreadId);
|
||||
int id;
|
||||
*H = CREATE_THREAD2(StackSize,ThreadMainHandler,this, (LPDWORD)&id);
|
||||
ThreadId = (unsigned long)id;
|
||||
|
||||
if ( *H == CREATE_THREAD_FAILED )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user