Re: [Boost-Users] Re: Thread library: get thread id
<alternative exemplar>
When I implemented the Leader-Follower thread pattern described by Schmidt,
et al in Pattern-Oriented Software Architecture, I couldn't figure out a
way around comparing the thread id to the current leader in the
promote_new_leader function. Probably lack of imagination and/or
experience on my part, but having the thread id sure made it easier.
"William E.
Kempf" To:
--- In Boost-Users@yahoogroups.com, "William E. Kempf"
wrote: olivier_debels said:
I'm using boost_1_29_0 and need to get the id of the current
thread.
Why?
I have several threads which pop messages from the queue. I want to keep track of what each thread pops (depending on some rules) without adding an extra parameter (threadId) in the pop-function.
I don't follow this.
By this way threads just call the pop-function (they don't know anything about the internal cooking of the queue). They get a message, which fulfills the rules (one of the rules is f.e. that no two threads can handle the same message at the same time).
How does a thread id figure into this? What little of this description I understand gives no need for a thread id. William E. Kempf Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
<alternative exemplar> When I implemented the Leader-Follower thread pattern described by Schmidt, et al in Pattern-Oriented Software Architecture, I couldn't figure out a way around comparing the thread id to the current leader in the promote_new_leader function. Probably lack of imagination and/or experience on my part, but having the thread id sure made it easier.
If all you need is comparisons, the boost::thread class provides this today. That's why I wanted specific requirements for a thread id. Currently the things a thread id can provide that thread does not, AFAIK, are the following: * Can be copied. * Can be turned into a unique string for printing/etc. These features will be accounted for, I just need to be sure these are the only features missing. William E. Kempf
<alternative exemplar> When I implemented the Leader-Follower thread pattern described by Schmidt, et al in Pattern-Oriented Software Architecture, I couldn't figure out a way around comparing the thread id to the current leader in the promote_new_leader function. Probably lack of imagination and/or experience on my part, but having the thread id sure made it easier.
If all you need is comparisons, the boost::thread class provides
--- In Boost-Users@yahoogroups.com, "William E. Kempf"
today. That's why I wanted specific requirements for a thread id. Currently the things a thread id can provide that thread does not, AFAIK, are the following:
* Can be copied. * Can be turned into a unique string for printing/etc.
These features will be accounted for, I just need to be sure these are the only features missing.
William E. Kempf
Ok, So instead of comparing id's we compare threads. Fine. This means I need a map of thread references instead of ids. If I have a thread reference and I want to check if it is the current active thread I can do the following? thread_ref == Thread(); As far as I understood calling the constructor without arguments returns the current thread. So I can compare that one with my thread references. That would be great! (I guess it is great) thx, Olivier.
olivier_debels said:
<alternative exemplar> When I implemented the Leader-Follower thread pattern described by Schmidt, et al in Pattern-Oriented Software Architecture, I couldn't figure out a way around comparing the thread id to the current leader in the promote_new_leader function. Probably lack of imagination and/or experience on my part, but having the thread id sure made it easier.
If all you need is comparisons, the boost::thread class provides
--- In Boost-Users@yahoogroups.com, "William E. Kempf"
wrote: this today. That's why I wanted specific requirements for a thread id. Currently the things a thread id can provide that thread does not, AFAIK, are the following:
* Can be copied. * Can be turned into a unique string for printing/etc.
These features will be accounted for, I just need to be sure these are the only features missing.
William E. Kempf
Ok,
So instead of comparing id's we compare threads. Fine. This means I need a map of thread references instead of ids.
If I have a thread reference and I want to check if it is the current active thread I can do the following?
thread_ref == Thread();
As far as I understood calling the constructor without arguments returns the current thread. So I can compare that one with my thread references. That would be great! (I guess it is great)
Accept there is no thread_ref in Boost.Threads. The current version of Boost.Threads *IS* going to stand in your way here, and I aknowledge that. I'm addressing the issues for the next version, but that's why I needed to know specifically what you need a thread id for. Is it only for comparisons and display? William E. Kempf
Accept there is no thread_ref in Boost.Threads. The current
version of
Boost.Threads *IS* going to stand in your way here, and I aknowledge that. I'm addressing the issues for the next version, but that's why I needed to know specifically what you need a thread id for. Is it only for comparisons and display?
William E. Kempf
Yes it is, so thread comparison will do. thx for the help and info, Olivier.
participants (3)
-
dick.bridges@tais.com
-
olivier_debels <olivier_debels@yahoo.com>
-
William E. Kempf