| 70 | } |
| 71 | |
| 72 | inline bool PbSubscribeWithCtx( |
| 73 | aimrt::channel::SubscriberRef& subscriber_ref, |
| 74 | const std::shared_ptr<const PyPbTypeSupport>& msg_type_support, |
| 75 | std::function<void(aimrt::channel::ContextRef, const pybind11::bytes&)>&& callback) { |
| 76 | static std::vector<std::shared_ptr<const PyPbTypeSupport>> py_ts_vec; |
| 77 | py_ts_vec.emplace_back(msg_type_support); |
| 78 | |
| 79 | return subscriber_ref.Subscribe( |
| 80 | msg_type_support->NativeHandle(), |
| 81 | [callback{std::move(callback)}]( |
| 82 | const aimrt_channel_context_base_t* ctx_ptr, |
| 83 | const void* msg_ptr, |
| 84 | aimrt_function_base_t* release_callback_base) { |
| 85 | aimrt::channel::SubscriberReleaseCallback release_callback(release_callback_base); |
| 86 | |
| 87 | const std::string& msg_buf = *static_cast<const std::string*>(msg_ptr); |
| 88 | auto ctx_ref = aimrt::channel::ContextRef(ctx_ptr); |
| 89 | |
| 90 | pybind11::gil_scoped_acquire acquire; |
| 91 | |
| 92 | auto msg_buf_bytes = pybind11::bytes(msg_buf); |
| 93 | callback(ctx_ref, msg_buf_bytes); |
| 94 | msg_buf_bytes.release(); |
| 95 | |
| 96 | pybind11::gil_scoped_release release; |
| 97 | |
| 98 | release_callback(); |
| 99 | }); |
| 100 | } |
| 101 | |
| 102 | inline void ExportPublisherRef(pybind11::object m) { |
| 103 | using aimrt::channel::PublisherRef; |
nothing calls this directly
no test coverage detected