projects
/
folly.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
std::chrono'ize EventBase::setLoadAvgMsec
[folly.git]
/
folly
/
io
/
async
/
ScopedEventBaseThread.h
diff --git
a/folly/io/async/ScopedEventBaseThread.h
b/folly/io/async/ScopedEventBaseThread.h
index e500aefc9c81fd96c0c4f81acfd64f121d434117..52824cd810d122baf634889e9c60ac603998a7d7 100644
(file)
--- a/
folly/io/async/ScopedEventBaseThread.h
+++ b/
folly/io/async/ScopedEventBaseThread.h
@@
-1,5
+1,5
@@
/*
/*
- * Copyright 201
5
Facebook, Inc.
+ * Copyright 201
7
Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-18,11
+18,13
@@
#include <memory>
#include <thread>
#include <memory>
#include <thread>
+
#include <folly/io/async/EventBase.h>
#include <folly/io/async/EventBase.h>
-#include <folly/io/async/EventBaseManager.h>
namespace folly {
namespace folly {
+class EventBaseManager;
+
/**
* A helper class to start a new thread running a EventBase loop.
*
/**
* A helper class to start a new thread running a EventBase loop.
*
@@
-32,34
+34,30
@@
namespace folly {
*/
class ScopedEventBaseThread {
public:
*/
class ScopedEventBaseThread {
public:
- explicit ScopedEventBaseThread(
- bool autostart = true,
- EventBaseManager* ebm = nullptr);
- explicit ScopedEventBaseThread(
- EventBaseManager* ebm);
+ ScopedEventBaseThread();
+ explicit ScopedEventBaseThread(EventBaseManager* ebm);
~ScopedEventBaseThread();
~ScopedEventBaseThread();
- ScopedEventBaseThread(ScopedEventBaseThread&& other) noexcept;
- ScopedEventBaseThread &operator=(ScopedEventBaseThread&& other) noexcept;
-
- /**
- * Get a pointer to the EventBase driving this thread.
- */
EventBase* getEventBase() const {
EventBase* getEventBase() const {
- return
eventBase_.get()
;
+ return
&eb_
;
}
}
- void start();
-
void stop
();
- bool running();
+ std::thread::id getThreadId() const {
+
return th_.get_id
();
+ }
private:
private:
+ ScopedEventBaseThread(ScopedEventBaseThread&& other) = delete;
+ ScopedEventBaseThread& operator=(ScopedEventBaseThread&& other) = delete;
+
ScopedEventBaseThread(const ScopedEventBaseThread& other) = delete;
ScopedEventBaseThread& operator=(const ScopedEventBaseThread& other) = delete;
EventBaseManager* ebm_;
ScopedEventBaseThread(const ScopedEventBaseThread& other) = delete;
ScopedEventBaseThread& operator=(const ScopedEventBaseThread& other) = delete;
EventBaseManager* ebm_;
- std::unique_ptr<EventBase> eventBase_;
- std::unique_ptr<std::thread> thread_;
+ union {
+ mutable EventBase eb_;
+ };
+ std::thread th_;
};
}
};
}