X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2Fio%2Fasync%2FScopedEventBaseThread.cpp;h=7821d17baf34495fdc242f8fcf4111396341a81b;hp=29a44592729f55289b6bf95c8243888bf84a38a7;hb=c5992522f6c82653c5cfaca69ca3e1cff9995310;hpb=d807e4c12d51b00183cc2fcc13d75fb3ec0e412c diff --git a/folly/io/async/ScopedEventBaseThread.cpp b/folly/io/async/ScopedEventBaseThread.cpp index 29a44592..7821d17b 100644 --- a/folly/io/async/ScopedEventBaseThread.cpp +++ b/folly/io/async/ScopedEventBaseThread.cpp @@ -23,12 +23,29 @@ using namespace std; namespace folly { -ScopedEventBaseThread::ScopedEventBaseThread(bool autostart) { +static void run(EventBaseManager* ebm, EventBase* eb) { + if (ebm) { + ebm->setEventBase(eb, false); + } + CHECK_NOTNULL(eb)->loopForever(); + if (ebm) { + ebm->clearEventBase(); + } +} + +ScopedEventBaseThread::ScopedEventBaseThread( + bool autostart, + EventBaseManager* ebm) : + ebm_(ebm) { if (autostart) { start(); } } +ScopedEventBaseThread::ScopedEventBaseThread( + EventBaseManager* ebm) : + ScopedEventBaseThread(true, ebm) {} + ScopedEventBaseThread::~ScopedEventBaseThread() { stop(); } @@ -44,7 +61,7 @@ void ScopedEventBaseThread::start() { return; } eventBase_ = make_unique(); - thread_ = make_unique(&EventBase::loopForever, &*eventBase_); + thread_ = make_unique(run, ebm_, eventBase_.get()); eventBase_->waitUntilRunning(); }