X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2Ffibers%2FFiberManagerInternal.h;h=f94478944f8e1345d6f32899704364ec73c8a17f;hb=e70058f47d312aaf194207ff6034089850750c1e;hp=12669c7c9cfaa98de1b1ecbc65394e68f706e348;hpb=691cd11c1fc271652b9a6db152071c25490a6c9e;p=folly.git diff --git a/folly/fibers/FiberManagerInternal.h b/folly/fibers/FiberManagerInternal.h index 12669c7c..f9447894 100644 --- a/folly/fibers/FiberManagerInternal.h +++ b/folly/fibers/FiberManagerInternal.h @@ -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. @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -145,7 +146,7 @@ class FiberManager : public ::folly::Executor { std::unique_ptr loopController, Options options = Options()); - ~FiberManager(); + ~FiberManager() override; /** * Controller access. @@ -155,10 +156,13 @@ class FiberManager : public ::folly::Executor { /** * Keeps running ready tasks until the list of ready tasks is empty. - * - * @return True if there are any waiting tasks remaining. */ - bool loopUntilNoReady(); + void loopUntilNoReady(); + + /** + * This should only be called by a LoopController. + */ + void loopUntilNoReadyImpl(); /** * @return true if there are outstanding tasks. @@ -250,7 +254,7 @@ class FiberManager : public ::folly::Executor { T& local(); template - static T& localThread(); + FOLLY_EXPORT static T& localThread(); /** * @return How many fiber objects (and stacks) has this manager allocated. @@ -333,7 +337,7 @@ class FiberManager : public ::folly::Executor { template RemoteTask(F&& f, const Fiber::LocalData& localData_) : func(std::forward(f)), - localData(folly::make_unique(localData_)), + localData(std::make_unique(localData_)), rcontext(RequestContext::saveContext()) {} folly::Function func; std::unique_ptr localData; @@ -341,8 +345,8 @@ class FiberManager : public ::folly::Executor { AtomicIntrusiveLinkedListHook nextRemoteTask; }; - intptr_t activateFiber(Fiber* fiber); - intptr_t deactivateFiber(Fiber* fiber); + void activateFiber(Fiber* fiber); + void deactivateFiber(Fiber* fiber); typedef folly::IntrusiveList FiberTailQueue; typedef folly::IntrusiveList @@ -358,7 +362,7 @@ class FiberManager : public ::folly::Executor { FiberTailQueue readyFibers_; /**< queue of fibers ready to be executed */ FiberTailQueue yieldedFibers_; /**< queue of fibers which have yielded execution */ - FiberTailQueue fibersPool_; /**< pool of unitialized Fiber objects */ + FiberTailQueue fibersPool_; /**< pool of uninitialized Fiber objects */ GlobalFiberTailQueue allFibers_; /**< list of all Fiber objects owned */ @@ -373,8 +377,6 @@ class FiberManager : public ::folly::Executor { */ size_t maxFibersActiveLastPeriod_{0}; - FContext::ContextStruct mainContext_; /**< stores loop function context */ - std::unique_ptr loopController_; bool isLoopScheduled_{false}; /**< was the ready loop scheduled to run? */ @@ -476,6 +478,7 @@ class FiberManager : public ::folly::Executor { void* fakeStack, const void** saveStackBase, size_t* saveStackSize); + void freeFakeStack(void* fakeStack); void unpoisonFiberStack(const Fiber* fiber); #endif // FOLLY_SANITIZE_ADDRESS