Add OpenSSLCertUtils functions for DER encoding/decoding.
[folly.git] / folly / experimental / ThreadedRepeatingFunctionRunner.cpp
index a309f01ad826aca1ed4b34723069dab6bb4b19a3..82ab4081a09caeb2147483da713cee8c5becd499 100644 (file)
@@ -15,6 +15,7 @@
  */
 #include "folly/experimental/ThreadedRepeatingFunctionRunner.h"
 
+#include <folly/ThreadName.h>
 #include <glog/logging.h>
 #include <iostream>
 
@@ -53,13 +54,18 @@ bool ThreadedRepeatingFunctionRunner::stopImpl() {
 }
 
 void ThreadedRepeatingFunctionRunner::add(
+    std::string name,
     RepeatingFn fn,
     std::chrono::milliseconds initialSleep) {
-  threads_.emplace_back(
-      &ThreadedRepeatingFunctionRunner::executeInLoop,
-      this,
-      std::move(fn),
-      initialSleep);
+  threads_.emplace_back([
+    name = std::move(name),
+    fn = std::move(fn),
+    initialSleep,
+    this
+  ]() mutable {
+    setThreadName(name);
+    executeInLoop(std::move(fn), initialSleep);
+  });
 }
 
 bool ThreadedRepeatingFunctionRunner::waitFor(