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

implement the correct behaviour for ScalarAccessor::read() in case of UpdateMode::poll

parent 4bb0d1ea
No related branches found
No related tags found
No related merge requests found
......@@ -31,12 +31,16 @@ namespace ChimeraTK {
{}
/** Read an input variable. In case of an output variable, an exception will be thrown. This function will block
* the calling thread until the variable has been read. If the wait_for_new_data access mode flag has been set
* when creating the accessor, this function will wait until a new value has been provided to the variable. If
* a new value is already available before calling this function, the function will be non-blocking and
* lock-free. */
* the calling thread until the variable has been read. If the UpdateMode::push flag has been set when creating
* the accessor, this function will wait until a new value has been provided to the variable. If a new value is
* already available before calling this function, the function will be non-blocking and lock-free. */
void read() {
while(impl->receive() == false) usleep(1); // @todo TODO proper blocking implementation
if(Accessor<UserType>::_mode == UpdateMode::push) {
while(impl->receive() == false) usleep(1); // @todo TODO proper blocking implementation
}
else {
impl->receive();
}
}
/** Check if an input variable has new data. In case of an output variable, an exception will be thrown. If the
......@@ -92,23 +96,6 @@ namespace ChimeraTK {
return impl != nullptr;
}
boost::shared_ptr<ProcessVariable> createProcessVariable() {
// create pair of ProcessVariables
auto pair = createSynchronizedProcessScalar<UserType>("<local>");
// this is an output accessor: use sender as our implementation, return receiver
if(Accessor<UserType>::_direction == VariableDirection::output) {
impl = pair.first;
return pair.second;
}
else {
impl = pair.second;
return pair.first;
}
}
void useProcessVariable(boost::shared_ptr<ProcessVariable> &var) {
impl = boost::dynamic_pointer_cast< ProcessScalar<UserType> >(var);
if(!impl) {
......
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