Boost logo

Boost Users :

From: Paul Gregory (pgregory_at_[hidden])
Date: 2004-06-04 02:01:52


Hello all,

I am currently using Boost threads in a project I'm working on that involves
a server/client type communications system. The project is a 3D renderer,
the particular component is the communications between the renderer core,
and any number of interested display clients, which are responsible for
either displaying or storing the resulting image.

Within the main program I have a listener thread that waits for requests
from the display clients, and when it recieves one, launches another thread
to handle the response. The responder thread can often just construct and
send the response immediately. But if the request is for data that hasn't
yet been rendered, it needs to wait for the data to be available.

The responder is implemented as a class which has an operator() overload for
the thread function. I would like for the responder thread to first query
the system to see if the data is ready, and if not, block waiting for a
signal from the system to indicate it is ready. So I need a way for the
thread to 'register' it's interest in a particular data item with the main
system, then wait for the signal.

I presume there is a neat way of doing this using boost::mutexes and
boost::condition's but I can't quite work out how, I freely admint I'm not
very experienced when it comes to threaded programming. I've looked at the
Boost bounded_buffer.cpp tutorial and it does something similar, but I can't
work out how to apply the principles to my situation.

Any help is greatly appreciated.

Cheers

Paul Gregory

+---------------------------+---------------------------+
| email: pgregory_at_[hidden] | Web: http://www.aqsis.com |
| ICQ: 156088409 | AIM: aqsis1 |
+---------------------------+---------------------------+
| GnuPG: http://aqsis.sourceforge.net/0x9176E46C.asc |
+-------------------------------------------------------+


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net