Boost logo

Boost :

From: Stjepan Rajko (stipe_at_[hidden])
Date: 2007-05-19 14:20:37


Hello,

I have packed up and posted the most recent iteration of the remote
procedure call library.

Docs and code available at:
http://dancinghacker.com/code/rpc/

It is also available from the boost sandbox under /rpc

The major improvements are:

* futures are now used to handle return values and "out" parameters.
this allows the rpc library execute all of the calls asynchronously,
with the futures interface allowing the user to decide whether the
call indeed behaves asynchronously (by taking all the returned values
into proper futures) or behaves synchronously (either by storing a
return value into a non-future variable, where the future->variable
cast will block until the future is set, or by sending a non-future
variable as an "in/out" parameter)

* what gets to be marshaled back is completely determined by how the
call is made, rather than having to be specified explicitly:

// embed the function id and parameter for an int (int) call
rpc::call<std::string, int (int)> call_inc__1("inc", 1);
// if the returned handler is ignored, nothing is marshaled back:
client(call_inc__1);

// if the returned handler is stored in an acknowledgement, only a
confirmation of completion
// is marshaled back.
ack = client(call_inc__1);
BOOST_CHECK_NO_THROW(ack->completion().get());

// if the returned handler is stored in a proper handler, the return
value will be marshaled back
rpc::async_returning_handler<int>::ptr handler_int = client(call_inc__1);
boost::future<int> future_int(handler_int->return_promise());
BOOST_CHECK_EQUAL(future_int, 2);

// handler returners are imlplicitly convertible to futures, which
will carry the returned value
boost::future<int> result_inc = client(call_inc__1);
BOOST_CHECK_EQUAL(result_inc, 2);

// handler returners are also convertible to values, which immediately
// get assigned the value of the return value future, making the call
synchronous
int inced1 = client(call_inc__1);
BOOST_CHECK_EQUAL(inced1, 2);

More examples are in the HTML docs. Any feedback is welcome!

Thanks,

Stjepan

P.S. I contacted the author of the RCF library
(http://www.codeproject.com/threads/Rcf_Ipc_For_Cpp.asp) to see if he
wants to join efforts in making a boosty rpc lib, but unfortunatelly
he is too busy...


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