Skip to content

Commit

Permalink
Merge pull request #69 from sashacmc/fix_test
Browse files Browse the repository at this point in the history
Fix unittest and code cleanup:

* fix some notes from #65
* implement cleanupListener
* change listener storing key
* fix lambda transmission to zenoh
  • Loading branch information
gregmedd authored Jul 29, 2024
2 parents b701e35 + 8e8c9e0 commit 9499a4c
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 127 deletions.
32 changes: 4 additions & 28 deletions include/up-transport-zenoh-cpp/ZenohUTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,30 +90,6 @@ struct ZenohUTransport : public UTransport {
using CallableConn = typename UTransport::CallableConn;
using UuriKey = std::string;

struct ListenerKey {
CallableConn listener;
std::string zenoh_key;

ListenerKey(CallableConn listener, const std::string& zenoh_key)
: listener(listener), zenoh_key(zenoh_key) {}

bool operator==(const ListenerKey& other) const {
return listener == other.listener && zenoh_key == other.zenoh_key;
}

bool operator<(const ListenerKey& other) const {
if (listener == other.listener) {
return zenoh_key < other.zenoh_key;
}
return listener < other.listener;
}
};

using RpcCallbackMap = std::map<UuriKey, CallableConn>;
using SubscriberMap = std::map<ListenerKey, zenoh::Subscriber>;
using QueryableMap = std::map<ListenerKey, zenoh::Queryable>;
using QueryMap = std::map<std::string, zenoh::OwnedQueryPtr>;

/// @brief Register listener to be called when UMessage is received
/// for the given URI.
///
Expand Down Expand Up @@ -178,16 +154,16 @@ struct ZenohUTransport : public UTransport {

zenoh::Session session_;

RpcCallbackMap rpc_callback_map_;
std::map<UuriKey, CallableConn> rpc_callback_map_;
std::mutex rpc_callback_map_mutex_;

SubscriberMap subscriber_map_;
std::map<CallableConn, zenoh::Subscriber> subscriber_map_;
std::mutex subscriber_map_mutex_;

QueryableMap queryable_map_;
std::map<CallableConn, zenoh::Queryable> queryable_map_;
std::mutex queryable_map_mutex_;

QueryMap query_map_;
std::map<std::string, zenoh::OwnedQueryPtr> query_map_;
std::mutex query_map_mutex_;
};

Expand Down
Loading

0 comments on commit 9499a4c

Please sign in to comment.