Skip to content

Commit

Permalink
Start monitor thread when demanded by the attacher device
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBowman committed Jan 15, 2024
1 parent ffdb168 commit 04a77c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libraries/YarpPlugins/TechnosoftIpos/DeviceDriverImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ bool TechnosoftIposBase::open(yarp::os::Searchable & config)
}
}

return !monitorThread || monitorThread->start();
return true;
}

// -----------------------------------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions libraries/YarpPlugins/TechnosoftIpos/ICanBusSharerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ bool TechnosoftIposBase::initialize()
yCIWarning(IPOS, id()) << "Initial drive state transitions failed";
}

// the monitor thread itself may call `initialize()`, so we need to check to avoid starting twice
if (monitorThread && !monitorThread->isRunning() && !monitorThread->start())
{
yCIError(IPOS, id()) << "Unable to start monitor thread";
return false;
}

return true;
}

Expand Down

0 comments on commit 04a77c3

Please sign in to comment.