3 #include <boost/range/algorithm.hpp>
5 #include "post-office.hpp"
6 #include "reference-counter.hpp"
10 #include "succeed.hpp"
12 namespace monazilla { namespace GikoMona { namespace core { namespace communication {
14 post_office::post_office(const post_code& self_) : self_code(self_) {
15 gm_shmem = shared_memory(ipc::open_or_create, shared_memory_name, 1024 * 4);
16 auto my_mailbox = construct<mailbox>(gm_shmem, self_code);
18 if(auto obj = find<reference_counter>(gm_shmem, ref_counter_name)) {
19 auto locker = obj->scoped_lock();
22 construct<reference_counter>(gm_shmem, ref_counter_name);
26 post_office::~post_office() noexcept {
29 if(auto obj = find<reference_counter>(gm_shmem, ref_counter_name)) {
30 if(obj->count() == 1) {
31 destruct(gm_shmem, shared_memory_name);
33 auto locker = obj->scoped_lock();
41 bool post_office::connect(const post_code& connect_to) {
42 auto obj = find<mailbox>(gm_shmem, connect_to);
45 //mailbox_map[connect_to] = *obj;
46 send(connect_to, succeed::find_your_mailbox("").to_raw());
52 bool post_office::disconnect(const post_code& disconnect_from) {
53 return /*mailbox_map.erase(disconnect_from);*/ true;
56 mona_string post_office::receive(const post_code& originator_id) {
60 bool post_office::send_string(const post_code& to, mona_string&& src) {
61 auto obj = find<mailbox>(gm_shmem, to);
64 std::ostringstream str_builder;
65 //str_builder << self_ << "-" << src;