Skip to content

Commit

Permalink
Merge pull request #119 from DenisBiryukov91/dev/channels
Browse files Browse the repository at this point in the history
Channels Support
  • Loading branch information
milyin authored Jun 10, 2024
2 parents 517d42d + dd92de0 commit ee8f807
Show file tree
Hide file tree
Showing 31 changed files with 2,123 additions and 1,342 deletions.
2 changes: 1 addition & 1 deletion examples/simple/universal/z_simple.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class CustomSubscriber {
}

private:
Subscriber _sub;
Subscriber<void> _sub;
void on_receive(const Sample& sample) {
CustomStruct s = sample.get_payload().deserialize<CustomStruct>(CustomCodec());
std::cout << "Received: " << "{" << s.u << ", " << s.d << ", " << s.s << "}\n";
Expand Down
6 changes: 3 additions & 3 deletions examples/zenohc/z_get_channel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ int _main(int argc, char **argv) {
auto session = Session::open(std::move(config));

std::cout << "Sending Query '" << expr << "'...\n";
auto replies = session.get_reply_fifo_channel<FifoChannelType::Blocking>(
keyexpr, "", 16, {.target = QueryTarget::Z_QUERY_TARGET_ALL}
auto replies = session.get(
keyexpr, "", channels::FifoChannel(16), {.target = QueryTarget::Z_QUERY_TARGET_ALL}
);

for (auto reply = replies.get_next_reply(); replies.is_active() && reply; reply = replies.get_next_reply()) {
for (auto reply = replies.recv().first; static_cast<bool>(reply); reply = replies.recv().first) {
const auto& sample = reply.get_ok();
std::cout << "Received ('" << sample.get_keyexpr().as_string_view() << "' : '"
<< sample.get_payload().deserialize<std::string>() << "')\n";
Expand Down
6 changes: 3 additions & 3 deletions examples/zenohc/z_get_channel_non_blocking.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ int _main(int argc, char **argv) {

std::cout << "Sending Query '" << expr << "'...\n";

auto replies = session.get_reply_fifo_channel<FifoChannelType::NonBlocking>(
keyexpr, "", 16, {.target = QueryTarget::Z_QUERY_TARGET_ALL}
auto replies = session.get(
keyexpr, "", channels::FifoChannel(16), {.target = QueryTarget::Z_QUERY_TARGET_ALL}
);

for (auto reply = replies.get_next_reply(); replies.is_active(); reply = replies.get_next_reply()) {
for (auto [reply, alive] = replies.try_recv(); alive; std::tie(reply, alive) = replies.try_recv()) {
if (!reply) {
std::cout << ".";
std::this_thread::sleep_for(1s);
Expand Down
Loading

0 comments on commit ee8f807

Please sign in to comment.