Skip to content
Snippets Groups Projects
Commit 075359c4 authored by Martin Christoph Hierholzer's avatar Martin Christoph Hierholzer
Browse files

proper readAny implementation for the VariableGroup based on the new DeviceAccess features

parent 5f6a9c30
No related branches found
No related tags found
No related merge requests found
......@@ -83,6 +83,9 @@ namespace ChimeraTK {
return node;
}
/** Return the implementation as a TransferElement */
virtual boost::shared_ptr<TransferElement> getTransferElement() = 0;
/** Explicitly return the node */
VariableNetworkNode& getNode() {
return node;
......@@ -158,6 +161,10 @@ namespace ChimeraTK {
node = VariableNetworkNode(*this);
}
boost::shared_ptr<TransferElement> getTransferElement() override {
return boost::static_pointer_cast<TransferElement>(impl);
}
protected:
Module *_owner;
......
......@@ -16,18 +16,20 @@ namespace ChimeraTK {
/*********************************************************************************************************************/
void VariableGroup::readAny() {
bool gotUpdate = false;
auto accessorList = getAccessorListRecursive();
while(!gotUpdate) { /// @todo TODO FIXME make proper blocking implementation
boost::this_thread::yield();
boost::this_thread::interruption_point();
for(auto accessor : accessorList) { // @todo FIXME make sure no submodule is accessing the variables itself... (e.g. by forcing all submodules to be a VariablGroup and not e.g. an ApplicationModule)
if(accessor->getUpdateMode() == UpdateMode::push) {
if(accessor->readNonBlocking()) gotUpdate = true;
}
// put push-type transfer elements into a list suitable for TransferElement::readAny()
std::list<std::reference_wrapper<TransferElement>> transferElementList;
for(auto &accessor : accessorList) {
if(accessor->getUpdateMode() == UpdateMode::push) {
transferElementList.emplace_back(*(accessor->getTransferElement()));
}
}
// wait until one of the push-type accessors receives an update
mtca4u::TransferElement::readAny(transferElementList);
// trigger read on the poll-type accessors
for(auto accessor : accessorList) {
if(accessor->getUpdateMode() == UpdateMode::poll) {
accessor->read();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment