Boost logo

Boost :

Subject: [boost] new version of Join library
From: Yigong Liu (yigongliu_at_[hidden])
Date: 2009-04-13 02:53:10


i just uploaded a new version of Join library to Vault/ Concurrent
A brief summary of Join library: an asynchronous message coordination and
concurrency library based on JoCaml and Cw. It provides a high level api of
asynchronous ports, synchronous ports, chords and joints which support
multithreaded applications and orchestration of asynchronous messages.

There are some major changes for this new version:
1. originally the library is structured as 2 layers: a port api at bottom
and a function api at top. In this new version, function level api is
dropped to simplify the interface and implementation. There are some
benefits coming with it:
   1> the signature of chord's function can be directly mapped from the
types of its ports, there is no need for argument wrappers (async_o,
synch_o) anymore. so a thread safe message queue can be defined as:
    template <typename T>
    class msg_que : public joint {
       async<T> send;
       synch<T,void> recv;
       msg_que() {
        chord(recv, send, &msg_que::proc);
       T proc(void_t, T s) { return s; }
   2> we can use boost::lambda or phoenix to define chord's function; so the
above class becomes:
    template <typename T>
    class msg_que {
       async<T> send;
       synch<T,void> recv;
       msg_que() {
          joins().chord(recv, send, _2);

2. apply "pimpl" idiom to major port classes and joint class. the benefits
of this:
   1> port/joint classes play well with standard c++ containers and other
   2> better control of lifetime of port/joint objects
   3> we can do JoCaml (functional) style "Join" programming, instead of
Cw's class based design. For example the msg_que can be created using
"factory" function as in JoCaml:
    template <typename T>
    tuple<async<T>, synch<T,void> > create_msg_que() {
       async<T> send;
       synch<T,void> recv;
       return make_tuple(send,recv);
     So the code which uses this "factory" function look like this:
    async<int> send;
    synch<int,void> recv;
    tie(send,recv) = create_msg_que<int>();
    //spawn 2 threads, thread1 creates data and send it, thread2 receives
and use data
    spawn(bind(thread1_func, send));
    spawn(bind(thread2_func, recv));

The documents and samples are updated. You can view them from the following
You can download it from Vault / Concurrent Programming or the project

Comments and corrections are highly appreciated.


Boost list run by bdawes at, gregod at, cpdaniel at, john at