Publisher and Subscriber handles returned by Unit::Advertise() / Unit::Subscribe(), or directly through TransportManager when building lower-level components.
All types live in the
basis::core::transport namespace unless noted otherwise.
Header paths are relative to cpp/core/transport/include/.Publisher<T_MSG, T_CONVERTABLE_INPROC>
basis/core/transport/publisher.h
A typed handle for publishing messages on a topic. Owns serialization callbacks and delegates to one or more underlying TransportPublisher instances (e.g. TCP) plus an optional inproc channel.
Template parameters
The primary message type. Must be serializable via
T_Serializer.An optional secondary inproc-only type. When set, callers may also publish
std::shared_ptr<const T_CONVERTABLE_INPROC> directly; the publisher converts it to T_MSG before network delivery.Publish (primary message)
msg to all subscribers. The message is:
- Delivered directly (zero-copy) to inproc subscribers.
- Serialized and sent over all registered network transports if any transport subscribers exist.
- Written to the recorder if one is attached and the topic matches its filter.
The message to publish. Ownership is shared; inproc subscribers receive the same pointer.
Publish (convertable inproc type)
T_CONVERTABLE_INPROC != NoAdditionalInproc. Sends msg over the additional inproc channel immediately, then calls ConvertToMessage<T_MSG>(msg) and routes the result through the primary path if any transport or primary inproc subscribers are present.
PublishRaw (base class)
PublisherBase. Sends a pre-serialized MessagePacket to all transport publishers and, when a recorder is attached, writes the packet payload to disk.
SetMaxQueueSize
Maximum number of serialized packets that may be queued per transport before back-pressure is applied.
GetTransportSubscriberCount
PublisherRaw
basis/core/transport/publisher.h
A non-templated publisher that accepts pre-serialized MessagePacket objects. Useful when the serialized form is produced externally (e.g. during replay).
SubscriberCallback<T_MSG>
basis/core/transport/subscriber.h
Type alias for the callback signature used by all typed subscribers.
Subscriber<T_MSG, T_ADDITIONAL_INPROC>
basis/core/transport/subscriber.h
A typed subscriber handle. Created by TransportManager::Subscribe() or Unit::Subscribe(). Holds inproc channel subscriptions and a list of underlying TransportSubscriber objects for network transports.
Template parameters
Primary message type. Callbacks receive
std::shared_ptr<const T_MSG>.Optional secondary inproc type. When set, a second callback fires with
std::shared_ptr<const T_ADDITIONAL_INPROC> for messages delivered over the additional inproc channel.Public members
using MessageType = T_MSG. Convenience alias for the primary message type.Inherited from SubscriberBase
TransportManager when the coordinator reports new publishers. Routes each publisher to the appropriate transport.
RateSubscriber
basis/core/transport/subscriber.h
A timer-based trigger that fires a callback at a fixed rate, independent of any topic. Commonly used to implement periodic handlers in generated unit code.
Constructor
Period between invocations. The timer fires approximately every
tick_length nanoseconds of monotonic time.Called on each tick with the current
MonotonicTime. Runs on the rate subscriber’s internal thread.Start / Stop
Start() is called automatically by the constructor. Stop() joins the internal thread and is called by the destructor.
TransportManager
basis/core/transport/transport_manager.h
Central coordinator for publishers and subscribers within a single process. Creates typed publish/subscribe handles, routes inproc messages, and aggregates publisher metadata for the coordinator.
Constructor
Optional inproc transport. When provided, messages published on a topic are delivered zero-copy to subscribers in the same process.
Advertise
Publisher. Registers the message schema, sets up inproc and network transport publishers, and optionally attaches the recorder.
Message type to publish.
Serializer for
T_MSG.Secondary inproc type, if any.
Topic name.
Type metadata. Deduced when omitted.
AdvertiseRaw
Subscribe
std::function callback. Internally calls SubscribeCallable.
Topic to subscribe to.
Invoked with each received
std::shared_ptr<const T_MSG>.Thread pool for deserializing and dispatching callbacks from network transports.
When set, callbacks are posted to this queue instead of being called directly. Enables serialized delivery in
SingleThreadedUnit.Type metadata. Deduced when omitted.
Callback for the secondary inproc type, if any.
SubscribeCallable
Subscribe but accepts any callable (lambda, function pointer, etc.), which avoids the overhead of std::function construction. T_MSG must be specified explicitly.
SubscribeRaw
RegisterTransport
Advertise and Subscribe calls will include this transport.
Update
GetLastPublisherInfo(). Called by StandardUpdate() on every unit tick.
SetRecorder
Advertise calls and only once.
Recorder that will receive serialized message payloads.
HandleNetworkInfo
CoordinatorConnector
basis/core/coordinator/include/basis/core/coordinator_connector.h
Maintains a TCP connection to the Basis coordinator process and handles topology updates (publisher discovery) and schema registration.
Factory: Create
127.0.0.1 on port. Returns nullptr if the coordinator is not yet available.
Port the coordinator is listening on. Uses the compile-time default when omitted.
Update
last_network_info, network_schemas, errors_from_coordinator). Call this on every tick.
SendTransportManagerInfo
SendSchemas
GetLastNetworkInfo
nullptr if none has arrived yet.
Free function: WaitForCoordinator
CoordinatorConnector::Create() succeeds. Equivalent to the loop inside Unit::WaitForCoordinatorConnection().