|
Boost : |
Subject: Re: [boost] Is there any interest in a library for actor programming?
From: Dominik Charousset (dominik.charousset_at_[hidden])
Date: 2013-06-06 05:36:45
On 18.05.2013, at 23:54, Vicente J. Botet Escriba <vicente.botet_at_[hidden]> wrote:
> This is really a lot of good and interesting work on your library.
>
> Moving all the library to the Boost standards would be quite a lot of
> work however. Replacing some classes by the corresponding Boost ones.
>
> I would see already several Boost libraries in your libcppa library:
> * Atoms
> * CowTuples
> * Dynamically Typed Tuples - type erased tuples
> * Tuples Pattern matching
> * Actors
I gave this some thoughts. cow_tuple and any_tuple use the same data representation underneath. In this way, there is no 'conversion' from one to the other. Assigning a cow_tuple to an any_tuple is trivial. To restore the type information, tuple_cast can be used. This cast also allows for wildcards:
auto t0 = make_cow_tuple(1, 2, 3, 4);
any_tuple t1 = t0;
auto opt = tuple_cast<anything, int, int>(t1);
if (opt) {
auto t2 = *opt;
cout << get<0>(t2) // will print 3
<< get<1>(t2) // will print 4
<< endl;
}
any_tuple provides the same copy-on-write behavior:
auto t0 = make_cow_tuple(1, "hello", "world"); // const char* is implicitly converted to std::string
any_tuple t1 = t0;
any_tuple t2 = t0;
assert(&t1.get_as<int>(0) == &t2.get_as<int>(0)); // same address
assert(&get<0>(t0) == &t1.get_as<int>(0)); // same address
t1.get_as_mutable<std::string>(2) = "libcppa";
assert(&t1.get_as<int>(0) != &t2.get_as<int>(0)); // no longer the same address
assert(&get<0>(t0) != &t1.get_as<int>(0)); // no longer the same address
Long story short: cow_tuple and any_tuple are closely related. any_tuple *is* a typed erased cow_tuple. Would it be beneficial to split them into two libraries? Any thoughts on that?
Currently, I'm reviewing the tuple classes and evaluate whether boost.serialization/boost::extended_type_info fit the needs of libcppa.
On 05.06.2013, at 15:48, Hartmut Kaiser <hartmut.kaiser_at_[hidden]> wrote:
> Just to reiterate, HPX (https://github.com/STEllAR-GROUP/hpx/) is a very
> similar library exposing actor oriented paradigms to the programmer (amongst
> other things), just wrapped up into a C++11 compliant interface (future,
> async, thread, bind, function, tuple, etc.). It's usable with C++03
> compliant compilers (I have not tried msvc-9.0, though). While not part of
> Boost, it strongly adheres to Boost coding guidelines and style and it is
> maintained by long standing Boost authors.
Hartmut, I can understand that you want to advertise your work, but hpx has nothing to do with actor programming. I saw your presentation at the C++Now conference. hpx offers a future-based API and you are proposing C#'s syntax for async/await (cf. N3564 [1]).
[1] http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2013/n3564.pdf
Best regards,
Dominik
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk