set thread name (#3664)

* set thread name

* fix dead lock

* fix code style & return fake name

* fix code style

* fix code style

Co-authored-by: Aleksandar Fabijanic <aleks-f@users.noreply.github.com>
This commit is contained in:
JackyWoo
2022-07-18 18:21:33 +08:00
committed by GitHub
parent 2a36359bc7
commit 1d28d2d42d
12 changed files with 240 additions and 60 deletions

View File

@@ -36,10 +36,8 @@
#include <cstring>
#endif
namespace Poco {
class Foundation_API ThreadImpl
{
public:
@@ -64,6 +62,12 @@ public:
~ThreadImpl();
TIDImpl tidImpl() const;
void setNameImpl(const std::string& threadName);
std::string getNameImpl() const;
std::string getOSThreadNameImpl();
/// Returns the thread's name, expressed as an operating system
/// specific name value. Return empty string if thread is not running.
/// For test used only.
void setPriorityImpl(int prio);
int getPriorityImpl() const;
void setOSPriorityImpl(int prio, int policy = SCHED_OTHER);
@@ -141,6 +145,7 @@ private:
std::size_t stackSize;
bool started;
bool joined;
std::string name;
mutable FastMutex mutex;
};