X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2Fio%2Fasync%2FEventBase.h;h=50d2aef8cd240bff0558be48c1ce7229ef2b1fa4;hp=670d6af65167950e378d78880156b0dd798743d5;hb=cacdd1d54a32c2740fa9dda4ac83b11d2d398820;hpb=dca6f3ea44d8fb0aaa1d4ae6761694b4ae9d0965 diff --git a/folly/io/async/EventBase.h b/folly/io/async/EventBase.h index 670d6af6..50d2aef8 100644 --- a/folly/io/async/EventBase.h +++ b/folly/io/async/EventBase.h @@ -1,5 +1,5 @@ /* - * Copyright 2017 Facebook, Inc. + * Copyright 2017-present Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #pragma once #include @@ -35,7 +34,6 @@ #include #include -#include #include #include #include @@ -47,6 +45,7 @@ #include #include #include +#include namespace folly { @@ -62,7 +61,7 @@ class EventBaseLocalBaseBase { virtual void onEventBaseDestruction(EventBase& evb) = 0; virtual ~EventBaseLocalBaseBase() = default; }; -} +} // namespace detail template class EventBaseLocal; @@ -95,6 +94,10 @@ class RequestEventBase : public RequestData { std::unique_ptr(new RequestEventBase(eb))); } + bool hasCallback() override { + return false; + } + private: explicit RequestEventBase(EventBase* eb) : eb_(eb) {} EventBase* eb_; @@ -146,6 +149,7 @@ class EventBase : private boost::noncopyable, virtual void runLoopCallback() noexcept = 0; void cancelLoopCallback() { + context_.reset(); unlink(); } @@ -194,6 +198,13 @@ class EventBase : private boost::noncopyable, Func function_; }; + /** + * Create a new EventBase object. + * + * Same as EventBase(true), which constructs an EventBase that measures time. + */ + EventBase() : EventBase(true) {} + /** * Create a new EventBase object. * @@ -203,7 +214,7 @@ class EventBase : private boost::noncopyable, * that relies on time-measurement, including: * observer, max latency and avg loop time. */ - explicit EventBase(bool enableTimeMeasurement = true); + explicit EventBase(bool enableTimeMeasurement); /** * Create a new EventBase object that will use the specified libevent