/*
- * 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.
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;
ScopedEventBaseThread& operator=(const ScopedEventBaseThread& other) = delete;
EventBaseManager* ebm_;
- mutable EventBase eb_;
+ union {
+ mutable EventBase eb_;
+ };
std::thread th_;
+ folly::Baton<> stop_;
};
-}
+} // namespace folly