|
Boost : |
From: Yigong Liu (yigongliu_at_[hidden])
Date: 2007-05-19 17:57:14
Hello,
Any interests in a boost asynchronous concurrency library based on Cw and
Join Calculus?
Boost.Join follows Cw's design and supports lock-free concurrent design with
a few abstractions:
1. asynchronous methods: async<void (T1, T2, ...)>
A asynchronous method is one-way, no-result, non-blocking call;
essentially passing a message. A asynchronous call is guaranteed to return
immediately; internally there could be a queue to buffer the arguments or
message.
2. synchronous methods: synch<R (T1, T2, ...)>
A synchronous call will block till result is returned. However a
synchronous call is different from normal method call in that it involves
multithreads and synchronization.
3. chords or "joined" method body definition:
for a normal function/method, there is 1-1 exact correspondence between a
function header/signature and its body. In Cw and Boost.Join, a body can be
associated with a set of (synchronous and/or asynchronous) methods. Such a
definition is called "chord". A particular async/synch method may appear in
the header of several chords. The body of a chord can only execute when all
the methods in its header have been called.
In Boost.Join, a thread safe buffer can be defined as following:
class buffer: public actor<> {
public:
async<void(string)> put;
synch<string(void)> get;
buffer() {
chord(put, get, &buffer::chord_body);
}
void chord_body(async_o<void(string)> put, synch_o<string(void)> get) {
get.reply(put.arg1); //or equally, get.reply(put);
}
};
such a buffer can be safely used in multithreaded applications:
buffer b;
b.put("Hello"); b.put("World");
cout << b.get() << b.get() << endl;
More detailed info can be found at http://channel.sourceforge.net
Over a dozen samples are provided, mostly using Boost.Join to implement
common concurrency idioms such as semaphores, futures and active objects.
Boost.Join is a header only library. All code and samples build and run in
Linux with g++ and Windows with VC++2005express.
Comments, suggestions and corrections are highly appreciated!
Thanks
Yigong
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk