SDK: Track channel to task id association

This commit is contained in:
Dennis Klein
2019-07-28 11:59:10 +02:00
committed by Dennis Klein
parent 008be36125
commit fd282fa950
4 changed files with 35 additions and 3 deletions

View File

@@ -20,7 +20,9 @@
#include <cassert>
#include <cstdlib>
#include <mutex>
#include <sstream>
#include <unordered_map>
#include <utility>
namespace fair {
@@ -134,6 +136,8 @@ struct DDSSession::Impl
dds::intercom_api::CCustomCmd fDDSCustomCmd;
Id fId;
bool fStopOnDestruction;
mutable std::mutex fMtx;
std::unordered_map<DDSChannel::Id, DDSTask::Id> fTaskIdByChannelIdMap;
};
DDSSession::DDSSession(DDSEnvironment env)
@@ -316,6 +320,18 @@ void DDSSession::UnsubscribeFromCommands()
void DDSSession::SendCommand(const std::string& cmd) { fImpl->fDDSCustomCmd.send(cmd, ""); }
auto DDSSession::UpdateChannelToTaskAssociation(DDSChannel::Id channelId, DDSTask::Id taskId) -> void
{
std::lock_guard<std::mutex> lk(fImpl->fMtx);
fImpl->fTaskIdByChannelIdMap[channelId] = taskId;
}
auto DDSSession::GetTaskId(DDSChannel::Id channelId) const -> DDSTask::Id
{
std::lock_guard<std::mutex> lk(fImpl->fMtx);
return fImpl->fTaskIdByChannelIdMap.at(channelId);
}
auto operator<<(std::ostream& os, const DDSSession& session) -> std::ostream&
{
return os << "$DDS_SESSION_ID: " << session.GetId();