ProxyPushSupplierManager::run() source code

Multithreaded Programming

code: ProxyPushSupplierManager::run_undetached()

The code triggers each of a set of ProxyPushSupplier objects in turn. Each supplier pulls messages from a central queue and sends them to a remote PushConsumer object. When triggered, suppliers set the 'busy' flag if they actually do something, they set the 'waiting' flag if they are expecting a response from their consumer, or they set neither flag if they are idle.

The run() method uses the values of these flags to judge how often the supplier objects should be triggered.

I've used a condition variable to pause the thread when new events are added to the central queue. That's done by either of these send() methods:

code: ConsumerAdmin_i::send(event)
code: ConsumerAdmin_i::send(events)

Notice the use of class PauseThenWake which pauses the thread upon construction and signals it to wake up on destruction.

This example uses omniORB's omnithread class - a thin wrapper around POSIX threads. omnithread is a portability wrapper that makes it easy to port thread code across a wide variety of architectures.

Portfolio Multithreaded Programming Unix Daemon & Windows Service Windows Registry GNU Autoconf Documentation Web Design Java Python

2005, Alex Tingle. This work is licensed under a Creative Commons License.
Permission granted to copy but NOT TO MODIFY this document.