mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 16:46:47 +00:00
SDK: Allow passing path to Set/GetProperties
This commit is contained in:
parent
50dacbcdde
commit
92af823135
|
@ -524,6 +524,7 @@ class BasicTopology : public AsioBase<Executor, Allocator>
|
|||
public:
|
||||
template<typename CompletionToken>
|
||||
auto AsyncGetProperties(DevicePropertyQuery const& query,
|
||||
const std::string& path,
|
||||
Duration timeout,
|
||||
CompletionToken&& token)
|
||||
{
|
||||
|
@ -536,7 +537,7 @@ class BasicTopology : public AsioBase<Executor, Allocator>
|
|||
std::piecewise_construct,
|
||||
std::forward_as_tuple(id),
|
||||
std::forward_as_tuple(id,
|
||||
fStateData.size(),
|
||||
fDDSTopo.GetTasks(path).size(),
|
||||
timeout,
|
||||
fMtx,
|
||||
AsioBase<Executor, Allocator>::GetExecutor(),
|
||||
|
@ -544,7 +545,7 @@ class BasicTopology : public AsioBase<Executor, Allocator>
|
|||
std::move(handler)));
|
||||
|
||||
cmd::Cmds const cmds(cmd::make<cmd::GetProperties>(id, query));
|
||||
fDDSSession.SendCommand(cmds.Serialize());
|
||||
fDDSSession.SendCommand(cmds.Serialize(), path);
|
||||
},
|
||||
token);
|
||||
}
|
||||
|
@ -552,17 +553,16 @@ class BasicTopology : public AsioBase<Executor, Allocator>
|
|||
template<typename CompletionToken>
|
||||
auto AsyncGetProperties(DevicePropertyQuery const& query, CompletionToken&& token)
|
||||
{
|
||||
return AsyncGetProperties(query, Duration(0), std::move(token));
|
||||
return AsyncGetProperties(query, "", Duration(0), std::move(token));
|
||||
}
|
||||
|
||||
auto GetProperties(DevicePropertyQuery const& query, Duration timeout = Duration(0))
|
||||
auto GetProperties(DevicePropertyQuery const& query, const std::string& path = "", Duration timeout = Duration(0))
|
||||
-> std::pair<std::error_code, GetPropertiesResult>
|
||||
{
|
||||
tools::SharedSemaphore blocker;
|
||||
std::error_code ec;
|
||||
GetPropertiesResult result;
|
||||
AsyncGetProperties(
|
||||
query, timeout, [&, blocker](std::error_code _ec, GetPropertiesResult _result) mutable {
|
||||
AsyncGetProperties(query, path, timeout, [&, blocker](std::error_code _ec, GetPropertiesResult _result) mutable {
|
||||
ec = _ec;
|
||||
result = _result;
|
||||
blocker.Signal();
|
||||
|
@ -663,6 +663,7 @@ class BasicTopology : public AsioBase<Executor, Allocator>
|
|||
public:
|
||||
template<typename CompletionToken>
|
||||
auto AsyncSetProperties(const DeviceProperties& props,
|
||||
const std::string& path,
|
||||
Duration timeout,
|
||||
CompletionToken&& token)
|
||||
{
|
||||
|
@ -675,7 +676,7 @@ class BasicTopology : public AsioBase<Executor, Allocator>
|
|||
std::piecewise_construct,
|
||||
std::forward_as_tuple(id),
|
||||
std::forward_as_tuple(id,
|
||||
fStateData.size(),
|
||||
fDDSTopo.GetTasks(path).size(),
|
||||
timeout,
|
||||
fMtx,
|
||||
AsioBase<Executor, Allocator>::GetExecutor(),
|
||||
|
@ -683,7 +684,7 @@ class BasicTopology : public AsioBase<Executor, Allocator>
|
|||
std::move(handler)));
|
||||
|
||||
cmd::Cmds const cmds(cmd::make<cmd::SetProperties>(id, props));
|
||||
fDDSSession.SendCommand(cmds.Serialize());
|
||||
fDDSSession.SendCommand(cmds.Serialize(), path);
|
||||
},
|
||||
token);
|
||||
}
|
||||
|
@ -691,17 +692,16 @@ class BasicTopology : public AsioBase<Executor, Allocator>
|
|||
template<typename CompletionToken>
|
||||
auto AsyncSetProperties(DeviceProperties const & properties, CompletionToken&& token)
|
||||
{
|
||||
return AsyncSetProperties(properties, Duration(0), std::move(token));
|
||||
return AsyncSetProperties(properties, "", Duration(0), std::move(token));
|
||||
}
|
||||
|
||||
auto SetProperties(DeviceProperties const& properties, Duration timeout = Duration(0))
|
||||
auto SetProperties(DeviceProperties const& properties, const std::string& path = "", Duration timeout = Duration(0))
|
||||
-> std::pair<std::error_code, FailedDevices>
|
||||
{
|
||||
tools::SharedSemaphore blocker;
|
||||
std::error_code ec;
|
||||
FailedDevices failed;
|
||||
AsyncSetProperties(
|
||||
properties, timeout, [&, blocker](std::error_code _ec, FailedDevices _failed) mutable {
|
||||
AsyncSetProperties(properties, path, timeout, [&, blocker](std::error_code _ec, FailedDevices _failed) mutable {
|
||||
ec = _ec;
|
||||
failed = _failed;
|
||||
blocker.Signal();
|
||||
|
|
|
@ -304,6 +304,7 @@ TEST_F(Topology, AsyncSetPropertiesTimeout)
|
|||
ASSERT_EQ(topo.ChangeState(TopologyTransition::InitDevice).first, std::error_code());
|
||||
|
||||
topo.AsyncSetProperties({{"key1", "val1"}},
|
||||
"",
|
||||
std::chrono::milliseconds(1),
|
||||
[=](std::error_code ec, sdk::FailedDevices) mutable {
|
||||
LOG(info) << ec;
|
||||
|
|
Loading…
Reference in New Issue
Block a user