Class InMemoryPubSubSession
Defined in File in_memory_pubsub_session.hpp
Base Type
public std::enable_shared_from_this< InMemoryPubSubSession >
-
class InMemoryPubSubSession : public std::enable_shared_from_this<InMemoryPubSubSession>
Process-global shared state for a group of in-memory pub/sub participants.
InMemoryPubSubSessionconsolidates theSharedInMemoryPubSubBackendandSharedInMemoryPubSubSessioninto a single, reusable class. It owns a sharedInMemoryDiscoveryandInMemoryTransport, and provides per-participant discovery/transport frontends that multiplex callbacks so that each PubSubContext’sinit_context()wiring is independent. This was implemented to enable test cases that involve launching multiple GXF contexts from the same process.Public Functions
-
~InMemoryPubSubSession()
-
Frontends create_frontends()
-
void join(gxf_context_t context)
Join this session from a specific GXF context.
-
void leave(gxf_context_t context)
Leave this session from a specific GXF context.
-
bool is_multi_context() const
Returns true if more than one distinct GXF context has joined.
-
inline const std::string &session_id() const
-
nvidia::gxf::Expected<void> ensure_backends()
-
nvidia::gxf::Expected<std::vector<nvidia::gxf::PublisherInfo>> query_publishers(const std::string &topic_name) const
-
nvidia::gxf::Expected<std::vector<nvidia::gxf::SubscriberInfo>> query_subscribers(const std::string &topic_name) const
-
nvidia::gxf::Expected<std::vector<std::string>> get_all_topics() const
-
bool wait_for_subscribers(const std::string &topic_name, size_t expected_count, std::chrono::milliseconds timeout) const
-
nvidia::gxf::Expected<void> send(const nvidia::gxf::Gid &destination_gid, const std::vector<uint8_t> &payload, const nvidia::gxf::MessageMetadata &metadata) const
-
nvidia::gxf::Expected<void> send(const nvidia::gxf::Gid &destination_gid, std::vector<uint8_t> &&payload, const nvidia::gxf::MessageMetadata &metadata) const
-
size_t send_queue_size() const
Public Static Functions
-
static std::shared_ptr<InMemoryPubSubSession> get_or_create(const std::string &session_id)
Get or create a session by ID. Thread-safe. Returns the same shared_ptr for the same session_id within the process.
-
static void reset_all_for_testing()
Release all sessions and reset shared state for tests. Must only be called when no session frontends are active.
-
struct Frontends
Create a paired discovery + transport frontend that share the same participant state. The discovery and transport frontends must be used together for a single PubSubContext — they share per-participant callback state so that PubSubContext::init_context() wiring is independent per context.
Public Members
-
std::shared_ptr<nvidia::gxf::PubSubDiscovery> discovery
-
std::shared_ptr<nvidia::gxf::PubSubTransport> transport
-
std::shared_ptr<nvidia::gxf::PubSubDiscovery> discovery
-
~InMemoryPubSubSession()