nifi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jeremyd...@apache.org
Subject nifi-minifi-cpp git commit: MINIFICPP-254: Resolve odd naming of isRunning variable so that it's clear we do not lock when we are running [Forced Update!]
Date Mon, 09 Oct 2017 15:26:43 GMT
Repository: nifi-minifi-cpp
Updated Branches:
  refs/heads/master b4cdf964d -> 380a98bb8 (forced update)


MINIFICPP-254: Resolve odd naming of isRunning variable so that it's clear we do not lock
when we are running

Originally identified by Fredrick Stakem.

This closes #143

Signed-off-by: Jeremy Dyer <jeremydyer@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/commit/380a98bb
Tree: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/tree/380a98bb
Diff: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/diff/380a98bb

Branch: refs/heads/master
Commit: 380a98bb85b185c109261b0bc3b0af878a57270e
Parents: 96d1874
Author: Marc Parisi <phrocker@apache.org>
Authored: Sun Oct 8 10:43:54 2017 -0400
Committer: Jeremy Dyer <jeremydyer@apache.org>
Committed: Mon Oct 9 11:26:10 2017 -0400

----------------------------------------------------------------------
 libminifi/src/core/Connectable.cpp | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/380a98bb/libminifi/src/core/Connectable.cpp
----------------------------------------------------------------------
diff --git a/libminifi/src/core/Connectable.cpp b/libminifi/src/core/Connectable.cpp
index cf01f0c..e2f033e 100644
--- a/libminifi/src/core/Connectable.cpp
+++ b/libminifi/src/core/Connectable.cpp
@@ -65,9 +65,11 @@ bool Connectable::setSupportedRelationships(std::set<core::Relationship>
relatio
 
 // Whether the relationship is supported
 bool Connectable::isSupportedRelationship(core::Relationship relationship) {
-  const bool requiresLock = isRunning();
+  // if we are running we do not need a lock since the function to change relationships_
( setSupportedRelationships)
+  // cannot be executed while we are running
+  const bool isConnectableRunning = isRunning();
 
-  const auto conditionalLock = !requiresLock ? std::unique_lock<std::mutex>() : std::unique_lock<std::mutex>(relationship_mutex_);
+  const auto conditionalLock = isConnectableRunning ? std::unique_lock<std::mutex>()
: std::unique_lock<std::mutex>(relationship_mutex_);
 
   const auto &it = relationships_.find(relationship.getName());
   if (it != relationships_.end()) {
@@ -95,9 +97,11 @@ bool Connectable::setAutoTerminatedRelationships(std::set<Relationship>
relation
 
 // Check whether the relationship is auto terminated
 bool Connectable::isAutoTerminated(core::Relationship relationship) {
-  const bool requiresLock = isRunning();
+  // if we are running we do not need a lock since the function to change relationships_
( setSupportedRelationships)
+    // cannot be executed while we are running
+  const bool isConnectableRunning = isRunning();
 
-  const auto conditionalLock = !requiresLock ? std::unique_lock<std::mutex>() : std::unique_lock<std::mutex>(relationship_mutex_);
+  const auto conditionalLock = isConnectableRunning ? std::unique_lock<std::mutex>()
: std::unique_lock<std::mutex>(relationship_mutex_);
 
   const auto &it = auto_terminated_relationships_.find(relationship.getName());
   if (it != auto_terminated_relationships_.end()) {


Mime
View raw message