From 023ef0f4cba7feef242a75c3c6e82a0c5d932b17 Mon Sep 17 00:00:00 2001 From: Raphael Grimm <raphael.grimm@kit.edu> Date: Wed, 25 Jul 2018 16:39:33 +0200 Subject: [PATCH] Clean up mutex usage --- .../RobotUnitModuleControlThreadDataBuffer.cpp | 5 +---- .../RobotUnitModules/RobotUnitModuleControllerManagement.cpp | 2 -- .../RobotUnitModules/RobotUnitModuleControllerManagement.h | 2 ++ 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleControlThreadDataBuffer.cpp b/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleControlThreadDataBuffer.cpp index 65efa415f..928863b7e 100644 --- a/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleControlThreadDataBuffer.cpp +++ b/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleControlThreadDataBuffer.cpp @@ -121,7 +121,6 @@ namespace armarx bool ControlThreadDataBuffer::sensorAndControlBufferChanged() const { throwIfInControlThread(BOOST_CURRENT_FUNCTION); - auto guard = getGuard(); throwIfDevicesNotReady(__FUNCTION__); return controlThreadOutputBuffer.updateReadBuffer(); } @@ -129,7 +128,6 @@ namespace armarx const SensorAndControl& ControlThreadDataBuffer::getSensorAndControlBuffer() const { throwIfInControlThread(BOOST_CURRENT_FUNCTION); - auto guard = getGuard(); throwIfDevicesNotReady(__FUNCTION__); return controlThreadOutputBuffer.getReadBuffer(); } @@ -137,7 +135,6 @@ namespace armarx void ControlThreadDataBuffer::writeRequestedControllers(JointAndNJointControllers&& setOfControllers) { throwIfInControlThread(BOOST_CURRENT_FUNCTION); - auto guard = getGuard(); throwIfDevicesNotReady(__FUNCTION__); //check NJoint const auto& nJointCtrls = setOfControllers.nJointControllers; @@ -235,7 +232,7 @@ namespace armarx void ControlThreadDataBuffer::setActivateControllersRequest(std::set<NJointControllerPtr, std::greater<NJointControllerPtr>> ctrls) { throwIfInControlThread(BOOST_CURRENT_FUNCTION); - auto guard = getGuard(); + std::lock_guard<std::recursive_mutex> guardRequested{controllersRequestedMutex}; throwIfDevicesNotReady(__FUNCTION__); //erase nullptr ctrls.erase(nullptr); diff --git a/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleControllerManagement.cpp b/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleControllerManagement.cpp index 7ae449768..824e460fa 100644 --- a/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleControllerManagement.cpp +++ b/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleControllerManagement.cpp @@ -66,14 +66,12 @@ namespace armarx Ice::StringSeq ControllerManagement::getRequestedNJointControllerNames(const Ice::Current&) const { throwIfInControlThread(BOOST_CURRENT_FUNCTION); - auto guard = getGuard(); return GetNonNullNames(_module<ControlThreadDataBuffer>().copyRequestedNJointControllers()); } Ice::StringSeq ControllerManagement::getActivatedNJointControllerNames(const Ice::Current&) const { throwIfInControlThread(BOOST_CURRENT_FUNCTION); - auto guard = getGuard(); return GetNonNullNames(_module<ControlThreadDataBuffer>().getActivatedNJointControllers()); } diff --git a/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleControllerManagement.h b/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleControllerManagement.h index 6530e53c1..49c90c949 100644 --- a/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleControllerManagement.h +++ b/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleControllerManagement.h @@ -429,6 +429,8 @@ namespace armarx std::map<std::string, NJointControllerPtr> nJointControllersToBeDeleted; /// @brief VirtualRobot used when creating controllers / calling other functions in this module VirtualRobot::RobotPtr controllerCreateRobot; + + std::recursive_mutex controllerMutex; // //////////////////////////////////////////////////////////////////////////////////////// // // /////////////////////////////////////// Attorneys ////////////////////////////////////// // // //////////////////////////////////////////////////////////////////////////////////////// // -- GitLab