Boost logo

Boost :

From: John Fuller (jfuller_at_[hidden])
Date: 2004-02-18 10:58:47


The project itself is a prototype implementation of ASAP as given
in wd-asap-spec-01d.doc found at the source forge project site under
references
for the easyasap package.

Sketch 5.2.2, for example, is a tar file containing the source code and
example logs.
For the sake of this topic, the concurrency directory holds files of
interest here.

My motivation is that I wanted to be able to "address" threads of
execution by a URI,
so I have "named" threads and channels.
In the implementation SOAP "dispatcher" thread gets messages,
deserializes them into "Request" objects and puts them on to a named
channel
consumed by a thread with the same name.
Actually, in reality, there is the factory service, service instance
and task level of execution,
but that's the idea.

Here's a brief description of include/concurrency:

Ted Yuan's ProducerConsumer.h provides a producer and consumer pattern
he describes
in the C/C++ Users Journal, January 2004, p28-31.
Consumers are sort of like the ACE Task active objects. The
descendants need to implement the consume(T) function to handle objects
taken from the channel, and may implement
cancel() to determine whether or not to exit early (or in my case, to
do work outside of
strictly serving the channel, like timing out on an outer state machine)
I've modified the code so that the consumer uses a timed wait if a
timeout is provided.
Things I'm not thrilled with are the way things need to be constructed
with references
and I think the source file should be broken up to include individual
files for the
template classes.

NamedThreads descends from boost::thread_group and maps names to thread
pointers.

ThreadCommunicationManager_t is a template class that by default
inherits from NamedThreads and further provides a map containing
pointers to channels,
registration and removal operations, and operations for putting an
object to a channel,
registering and starting a consumer if necessary.

ManagedConsumer_t is a template class for consumers
that contains a weak pointer to its thread manager and wraps access to
consumer members.

ManagedConsumerPrototyper_t is a template class that contains a weak
pointer
to its thread manager, wraps putting and joining operations and
provides an ancestor
for classes that create managed consumers. The idea originally was to
support
a prototyping factory pattern, but this was sort of foiled by the way
Consumers reference their channels. I've found a lot of trouble could
have been avoided if Consumers didn't reference channels the way they
do.

makeManagedConsumer_t is a template function for creating a managed
consumer
prototype, it creates the channel, latch, and consumer superclass.

In the example directory, tcm_demo.cc shows how
ThreadCommunicationManager_t
and makeManagedConsumer_t can be used.

I'm sure it could be cleaned up and improved, but thought I should
offer it.

On Feb 18, 2004, at 1:11 AM, Vladimir Prus wrote:

> John Fuller wrote:
>
>> A recent project of mine uses shared queues based on Ted Yuan's
>> producer-consumer
>> code. The producer consumer code has been modified to use timed
>> waits,
>> and
>> in my concurrency directory I provide management for named threads and
>> channels.
>>
>> See http://sourceforge.net/projects/easyasap/
>
> If would help if you send a pointer to docs or home page describing
> something. As it stands, I could find only large archive containing
> lots of
> files. It's hard to understand anything.
>
> - Volodya
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk