CARLA
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
carla::multigpu::SensorStreamRegistry Class Reference

Secondary-side map from a primary sensor actor to its local stream, exposed to clients only through an alias of the primary's stream id. More...

#include <sensorStreamRegistry.h>

Classes

struct  Entry
 

Public Types

using actor_id_type = uint32_t
 
using epoch_type = uint64_t
 
using stream_id_type = carla::streaming::detail::stream_id_type
 
using token_type = carla::streaming::detail::token_type
 

Public Member Functions

epoch_type BeginEpisodeChange (carla::streaming::Server &server)
 The primary switched episode: forgets every actor and returns the epoch the secondary must pass to OpenEpisode() once it runs the new episode.
 
std::optional< carla::streaming::Stream > Bind (carla::streaming::Server &server, actor_id_type actor_id, stream_id_type sensor_stream_id, bool can_adopt)
 Returns the stream reserved for actor_id if can_adopt (the sensor has never ticked) and the sensor must adopt it; otherwise the alias is retargeted to sensor_stream_id.
 
void CloseEpisode ()
 
bool IsEpisodeOpen ()
 Whether Bind()/Unbind() are accepted, i.e.
 
void OpenEpisode (epoch_type epoch)
 Accepts binding if epoch is the latest one BeginEpisodeChange() issued.
 
std::optional< token_type > Resolve (carla::streaming::Server &server, actor_id_type actor_id, stream_id_type primary_stream_id)
 Token that serves primary actor actor_id under primary_stream_id, reserving a local stream if the sensor has not spawned here yet.
 
void Unbind (carla::streaming::Server &server, actor_id_type actor_id)
 Forgets actor_id, closing its reserved stream if no sensor adopted it.
 

Static Private Member Functions

static void Forget (carla::streaming::Server &server, const Entry &entry)
 

Private Attributes

bool _bindable = false
 
std::unordered_map< actor_id_type, Entry > _entries
 
epoch_type _epoch = 0u
 
std::mutex _mutex
 

Detailed Description

Secondary-side map from a primary sensor actor to its local stream, exposed to clients only through an alias of the primary's stream id.

Entries are per primary episode. Resolve() and BeginEpisodeChange() run on the multi-GPU command thread, the rest on the game thread.

Definition at line 24 of file sensorStreamRegistry.h.

Member Typedef Documentation

◆ actor_id_type

Definition at line 26 of file sensorStreamRegistry.h.

◆ epoch_type

Definition at line 27 of file sensorStreamRegistry.h.

◆ stream_id_type

Definition at line 28 of file sensorStreamRegistry.h.

◆ token_type

Definition at line 29 of file sensorStreamRegistry.h.

Member Function Documentation

◆ BeginEpisodeChange()

SensorStreamRegistry::epoch_type carla::multigpu::SensorStreamRegistry::BeginEpisodeChange ( carla::streaming::Server &  server)

The primary switched episode: forgets every actor and returns the epoch the secondary must pass to OpenEpisode() once it runs the new episode.

Definition at line 112 of file sensorStreamRegistry.cpp.

References _bindable, _entries, _epoch, _mutex, and Forget().

Referenced by FCarlaEngine::NotifyInitGame().

◆ Bind()

std::optional< carla::streaming::Stream > carla::multigpu::SensorStreamRegistry::Bind ( carla::streaming::Server &  server,
actor_id_type  actor_id,
stream_id_type  sensor_stream_id,
bool  can_adopt 
)

Returns the stream reserved for actor_id if can_adopt (the sensor has never ticked) and the sensor must adopt it; otherwise the alias is retargeted to sensor_stream_id.

A stream bound to another actor is refused.

Definition at line 54 of file sensorStreamRegistry.cpp.

References _bindable, _entries, _mutex, carla::streaming::Server::CloseStream(), carla::log_warning(), and carla::streaming::Server::SetStreamAlias().

Referenced by FCarlaEngine::BindReplayedSensor().

◆ CloseEpisode()

void carla::multigpu::SensorStreamRegistry::CloseEpisode ( )

Definition at line 127 of file sensorStreamRegistry.cpp.

References _bindable, and _mutex.

Referenced by FCarlaEngine::NotifyEndEpisode().

◆ Forget()

void carla::multigpu::SensorStreamRegistry::Forget ( carla::streaming::Server &  server,
const Entry &  entry 
)
staticprivate

◆ IsEpisodeOpen()

bool carla::multigpu::SensorStreamRegistry::IsEpisodeOpen ( )

Whether Bind()/Unbind() are accepted, i.e.

the episode of the latest BeginEpisodeChange() is open.

Definition at line 132 of file sensorStreamRegistry.cpp.

References _bindable, and _mutex.

Referenced by FCarlaEngine::BindReplayedSensor(), and FCarlaEngine::OnBeginFrame().

◆ OpenEpisode()

void carla::multigpu::SensorStreamRegistry::OpenEpisode ( epoch_type  epoch)

Accepts binding if epoch is the latest one BeginEpisodeChange() issued.

Definition at line 122 of file sensorStreamRegistry.cpp.

References _bindable, _epoch, and _mutex.

Referenced by FCarlaEngine::NotifyBeginEpisode().

◆ Resolve()

std::optional< SensorStreamRegistry::token_type > carla::multigpu::SensorStreamRegistry::Resolve ( carla::streaming::Server &  server,
actor_id_type  actor_id,
stream_id_type  primary_stream_id 
)

◆ Unbind()

void carla::multigpu::SensorStreamRegistry::Unbind ( carla::streaming::Server &  server,
actor_id_type  actor_id 
)

Forgets actor_id, closing its reserved stream if no sensor adopted it.

Definition at line 97 of file sensorStreamRegistry.cpp.

References _bindable, _entries, _mutex, and Forget().

Referenced by FCarlaEngine::PlayPrimaryFrame().

Member Data Documentation

◆ _bindable

bool carla::multigpu::SensorStreamRegistry::_bindable = false
private

◆ _entries

std::unordered_map<actor_id_type, Entry> carla::multigpu::SensorStreamRegistry::_entries
private

Definition at line 79 of file sensorStreamRegistry.h.

Referenced by BeginEpisodeChange(), Bind(), Resolve(), and Unbind().

◆ _epoch

epoch_type carla::multigpu::SensorStreamRegistry::_epoch = 0u
private

Definition at line 77 of file sensorStreamRegistry.h.

Referenced by BeginEpisodeChange(), and OpenEpisode().

◆ _mutex

std::mutex carla::multigpu::SensorStreamRegistry::_mutex
private

The documentation for this class was generated from the following files: