Updating thread naming.

Also includes experimental code to adapt the thread name as shown by
top, but it's untested.
This commit is contained in:
Robin Sommer 2012-02-03 04:01:24 -08:00
parent cf6a346b86
commit 70fe7876a1
12 changed files with 81 additions and 14 deletions

View file

@ -34,16 +34,31 @@ public:
* @param name A descriptive name for thread the thread. This may
* show up in messages to the user.
*/
BasicThread(const string& name); // Managed by manager, must not delete otherwise.
BasicThread();
/**
* Returns a descriptive name for the thread. This is the name passed
* into the constructor.
* Returns a descriptive name for the thread. If not set via
* SetName(). If not set, a default name is choosen automatically.
*
* This method is safe to call from any thread.
*/
const string& Name() const { return name; }
/**
* Sets a descriptive name for the thread. This should be a string
* that's useful in output presented to the user and uniquely
* identifies the thread.
*
* This method must be called only from the thread itself.
*/
void SetName(const string& name);
/**
* Set the name shown by the OS as the thread's description. Not
* supported on all OSs.
*/
void SetOSName(const string& name);
/**
* Starts the thread. Calling this methods will spawn a new OS thread
* executing Run(). Note that one can't restart a thread after a