Hi,

just implement an internal mapping of thread id to thread pointer. It can be an unordered_map or stl::map, depends on how many threads you are going to manage.

Just a small addition to you code:

On Wed, Aug 27, 2008 at 7:06 PM, Christian Ost <christian.ost@gmail.com> wrote:
Hi,

I have a question concerning the removal from entries of a thread_group.
Consider the following code (i am working on a small threaded server):

in TCPServer.h:

boost::thread_group threads

in TCPServer.cpp:

int TCPServer::loop(int listen_fd) {
 for (;;) {
     [connect client]
     boost::thread* thrd = new
boost::thread(boost::bind(&TCPServer::readMessages, this, rfd));
     threads.add_thread(thrd);

this can be written:
boost::thread* thrd = threads.create_thread(boost::bind(&TCPServer::readMessages, this, rfd));
Here you don't need to call add_thread...


...

Regards,
Ovanes