9 #ifndef INCLUDE_PUBLISHER_H_ 10 #define INCLUDE_PUBLISHER_H_ 36 id =
getTempId(tentacle::role_t::PUBLISHER);
39 std::to_string(
sizeof(T)) +
" " + name);
41 std::pair<long, std::string> response;
45 std::istringstream iss(response.second);
46 std::vector<std::string> tokens{std::istream_iterator<std::string>{iss},
47 std::istream_iterator<std::string>{}};
48 if ((semid = semget(std::stoi(tokens[1]), 2, 0600)) < 0) {
49 throw std::system_error(
51 std::generic_category(),
52 "Unable to get r/w sem");
55 rw = reinterpret_cast<shm_object*>(
shared_data + std::stoi(tokens[0]));
57 data_ptr = reinterpret_cast<T*>(rw + 1);
58 id = std::stoi(tokens[2]);
68 bool return_value =
false;
69 if (
p(semid, 1) >= 0) {
78 if (
p(semid, 2) >= 0) {
85 if (
p(semid, 1) >= 0) {
108 #endif // INCLUDE_PUBLISHER_H_
static long getTempId(role_t role)
Definition: tentacle.cpp:72
Definition: publisher.h:27
Definition: tentacle.h:31
const unsigned CREATE_PUB
Definition: utility.h:38
publisher(std::string _name, key_t message_key)
Definition: publisher.h:34
bool write(long type, std::string data)
Definition: tentacle.cpp:50
int v(int sem, int counter)
Definition: utility.cpp:54
static std::pair< long, std::string > read(long type, bool block=true, bool under=false)
Definition: tentacle.cpp:28
bool publish(T data)
Definition: publisher.h:67
int p(int sem, int counter)
Definition: utility.cpp:39
unsigned rw_array[2]
Definition: utility.h:54
static intptr_t * shared_data
Definition: tentacle.h:47
const unsigned PUBLISH_CODE
Definition: utility.h:40