Clear frame cache when activating a fiber
[folly.git] / folly / fibers / EventBaseLoopController.h
index 017b75228af66511c36d52e5ff40fc606b118c92..5bc4e8cf38e07dbae3199ec9c1a61de814fda2e3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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 <folly/fibers/FiberManagerInternal.h>
 #include <folly/fibers/LoopController.h>
-#include <folly/io/async/EventBase.h>
+#include <folly/io/async/VirtualEventBase.h>
 #include <atomic>
 #include <memory>
 
-namespace folly {
-class EventBase;
-}
-
 namespace folly {
 namespace fibers {
 
 class EventBaseLoopController : public LoopController {
  public:
   explicit EventBaseLoopController();
-  ~EventBaseLoopController();
+  ~EventBaseLoopController() override;
 
   /**
    * Attach EventBase after LoopController was created.
    */
-  void attachEventBase(folly::EventBase& eventBase);
+  void attachEventBase(EventBase& eventBase);
+  void attachEventBase(VirtualEventBase& eventBase);
 
-  folly::EventBase* getEventBase() {
+  VirtualEventBase* getEventBase() {
     return eventBase_;
   }
 
@@ -63,7 +60,7 @@ class EventBaseLoopController : public LoopController {
   class DestructionCallback : public folly::EventBase::LoopCallback {
    public:
     DestructionCallback() : alive_(new int(42)) {}
-    ~DestructionCallback() {
+    ~DestructionCallback() override {
       reset();
     }
 
@@ -90,7 +87,8 @@ class EventBaseLoopController : public LoopController {
   };
 
   bool awaitingScheduling_{false};
-  folly::EventBase* eventBase_{nullptr};
+  VirtualEventBase* eventBase_{nullptr};
+  Executor::KeepAlive eventBaseKeepAlive_;
   ControllerCallback callback_;
   DestructionCallback destructionCallback_;
   FiberManager* fm_{nullptr};
@@ -103,13 +101,13 @@ class EventBaseLoopController : public LoopController {
   void setFiberManager(FiberManager* fm) override;
   void schedule() override;
   void cancel() override;
-  void runLoop();
+  void runLoop() override;
   void scheduleThreadSafe(std::function<bool()> func) override;
   void timedSchedule(std::function<void()> func, TimePoint time) override;
 
   friend class FiberManager;
 };
-}
-} // folly::fibers
+} // namespace fibers
+} // namespace folly
 
 #include "EventBaseLoopController-inl.h"