You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/08/01 15:29:10 UTC

[GitHub] [nifi-minifi-cpp] adam-markovics commented on a diff in pull request #1328: MINIFICPP-1812 - Clean up Repository threads

adam-markovics commented on code in PR #1328:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1328#discussion_r934658310


##########
libminifi/include/core/Repository.h:
##########
@@ -218,56 +195,77 @@ class Repository : public virtual core::SerializableComponent, public core::Trac
     return Put(key, buffer, bufferSize);
   }
 
-  uint64_t incrementSize(const char* /*fpath*/, const struct stat *sb, int /*typeflag*/) {
-    return (repo_size_ += sb->st_size);
-  }
-
   virtual void loadComponent(const std::shared_ptr<core::ContentRepository>& /*content_repo*/) {
   }
 
-  virtual uint64_t getRepoSize();
+  virtual uint64_t getRepoSize() const {
+    return repo_size_;
+  }
 
   std::string getDirectory() const {
     return directory_;
   }
 
-  // Prevent default copy constructor and assignment operation
-  // Only support pass by reference or pointer
-  Repository(const Repository &parent) = delete;
-  Repository &operator=(const Repository &parent) = delete;
+  // Starts repository monitor thread
+  void start() {
+    if (running_.exchange(true)) {
+      return;
+    }
+    if (purge_period_ <= std::chrono::milliseconds(0)) {
+      return;
+    }
+    getThread() = std::thread(&Repository::run, this);
+
+    logger_->log_debug("%s Repository monitor thread start", name_);
+  }
+
+  // Stops repository monitor thread
+  void stop() {
+    if (!running_.exchange(false)) {
+      return;
+    }
+    if (getThread().joinable()) {
+      getThread().join();
+    }
+    logger_->log_debug("%s Repository monitor thread stop", name_);
+  }

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org