Overview
Features
Download
Documentation
Community
Add-Ons & Services

Poco::Thread::setName

Please post support and help requests here.

Poco::Thread::setName

Postby jmansion » 23 Apr 2007, 17:49

Any reason why its protected?

It would be handy to be able to set the name of the *current* thread.

James
jmansion
 
Posts: 15
Joined: 01 Aug 2006, 14:42

Re: Poco::Thread::setName

Postby guenter » 25 Apr 2007, 16:50

Mostly because it's not thread safe (i.e., multiple threads calling setName() simultaneously (or simultaneous read/write access) will cause havoc...)
guenter
 
Posts: 1166
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: Re: Poco::Thread::setName

Postby jmansion » 26 Apr 2007, 10:14

> Mostly because it's not thread safe (i.e., multiple threads calling setName() simultaneously (or simultaneous read/write access) will cause havoc...)

I think that's lame! ;-)

1) It could be made thread safe.

2) Normally the use case is that the thread wants to change its own name, because of the context it is executing in.

Essentially I'm writing a different thread pool implementation. The current ThreadPool is only able to change the name using a friend, which indicates to me that there is a requirement and its hacked.

I think the underlying requirement is for something that represents (to a human) what the thread's activity (small 'a') is. And by convention to match Java, CLR etc we provide 'thread name' for that, as a special-case thread local in effect. But its not really the thread that needs a name (it has a handle for identity) its something that represents the binding of the thread to its current activity.

There ways to represent this other than via thread name, but that's the way that ThreadPool does it and it does follow existing practice.
jmansion
 
Posts: 15
Joined: 01 Aug 2006, 14:42

Re: Poco::Thread::setName

Postby guenter » 28 Apr 2007, 10:07

I have made setName() public and threadsafe. The change will show up in SVN soon.
guenter
 
Posts: 1166
Joined: 11 Jul 2006, 16:27
Location: Austria


Return to Support

Who is online

Users browsing this forum: No registered users and 0 guests

cron