Add MockTimeoutManager
[folly.git] / folly / Baton.h
index 7922ffd0246578f4b1c5375f14b05d3f5e7e9d1a..56ee49a34c87adcac34be0b84f570345fcc3557b 100644 (file)
@@ -19,7 +19,6 @@
 
 #include <stdint.h>
 #include <atomic>
-#include <boost/noncopyable.hpp>
 #include <errno.h>
 #include <assert.h>
 
@@ -44,8 +43,11 @@ namespace folly {
 /// a much more restrictive lifecycle we can also add a bunch of assertions
 /// that can help to catch race conditions ahead of time.
 template <template<typename> class Atom = std::atomic>
-struct Baton : boost::noncopyable {
-  Baton() : state_(INIT) {}
+struct Baton {
+  constexpr Baton() : state_(INIT) {}
+
+  Baton(Baton const&) = delete;
+  Baton& operator=(Baton const&) = delete;
 
   /// It is an error to destroy a Baton on which a thread is currently
   /// wait()ing.  In practice this means that the waiter usually takes
@@ -215,6 +217,13 @@ struct Baton : boost::noncopyable {
     }
   }
 
+  /// Similar to timed_wait, but with a duration.
+  template <typename Clock = std::chrono::steady_clock, typename Duration>
+  bool timed_wait(const Duration& duration) {
+    auto deadline = Clock::now() + duration;
+    return timed_wait(deadline);
+  }
+
   /// Similar to wait, but doesn't block the thread if it hasn't been posted.
   ///
   /// try_wait has the following semantics: