Consistently have the namespace closing comment
[folly.git] / folly / io / async / ScopedEventBaseThread.h
index c59b275e08e063c67a43294b974752bc8f44d937..c81ab3930410b0fb9b53fc891fb9e4320a657745 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 #include <memory>
 #include <thread>
+
+#include <folly/Baton.h>
 #include <folly/io/async/EventBase.h>
 
 namespace folly {
 
 class EventBaseManager;
+template <class Iter>
+class Range;
+typedef Range<const char*> StringPiece;
 
 /**
  * A helper class to start a new thread running a EventBase loop.
@@ -34,13 +39,21 @@ class EventBaseManager;
 class ScopedEventBaseThread {
  public:
   ScopedEventBaseThread();
+  explicit ScopedEventBaseThread(const StringPiece& name);
   explicit ScopedEventBaseThread(EventBaseManager* ebm);
+  explicit ScopedEventBaseThread(
+      EventBaseManager* ebm,
+      const StringPiece& name);
   ~ScopedEventBaseThread();
 
   EventBase* getEventBase() const {
     return &eb_;
   }
 
+  std::thread::id getThreadId() const {
+    return th_.get_id();
+  }
+
  private:
   ScopedEventBaseThread(ScopedEventBaseThread&& other) = delete;
   ScopedEventBaseThread& operator=(ScopedEventBaseThread&& other) = delete;
@@ -49,8 +62,11 @@ class ScopedEventBaseThread {
   ScopedEventBaseThread& operator=(const ScopedEventBaseThread& other) = delete;
 
   EventBaseManager* ebm_;
-  mutable EventBase eb_;
+  union {
+    mutable EventBase eb_;
+  };
   std::thread th_;
+  folly::Baton<> stop_;
 };
 
-}
+} // namespace folly