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
Date Mon, 09 Oct 2017 13:34:41 GMT
Repository: nifi-minifi-cpp
Updated Branches:
  refs/heads/master 96d187445 -> b4cdf964d


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/b4cdf964
Tree: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/tree/b4cdf964
Diff: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/diff/b4cdf964

Branch: refs/heads/master
Commit: b4cdf964dc9c383e50774f261528e76cc12ff3d2
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 09:32:53 2017 -0400

----------------------------------------------------------------------
 extensions/bluetooth/processors/BLEScanner.cpp |  5 +++++
 extensions/bluetooth/processors/BLEScanner.h   | 12 ++++++++++++
 libminifi/src/core/Connectable.cpp             | 12 ++++++++----
 3 files changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/b4cdf964/extensions/bluetooth/processors/BLEScanner.cpp
----------------------------------------------------------------------
diff --git a/extensions/bluetooth/processors/BLEScanner.cpp b/extensions/bluetooth/processors/BLEScanner.cpp
new file mode 100644
index 0000000..e4152c1
--- /dev/null
+++ b/extensions/bluetooth/processors/BLEScanner.cpp
@@ -0,0 +1,5 @@
+//
+// Created by Jeremy Dyer on 10/4/17.
+//
+
+#include "BLEScanner.h"

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/b4cdf964/extensions/bluetooth/processors/BLEScanner.h
----------------------------------------------------------------------
diff --git a/extensions/bluetooth/processors/BLEScanner.h b/extensions/bluetooth/processors/BLEScanner.h
new file mode 100644
index 0000000..40d61c8
--- /dev/null
+++ b/extensions/bluetooth/processors/BLEScanner.h
@@ -0,0 +1,12 @@
+//
+// Created by Jeremy Dyer on 10/4/17.
+//
+
+#ifndef NIFI_MINIFI_CPP_BLESCANNER_H
+#define NIFI_MINIFI_CPP_BLESCANNER_H
+
+class BLEScanner {
+
+};
+
+#endif //NIFI_MINIFI_CPP_BLESCANNER_H

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/b4cdf964/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