/*
- * 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 <vector>
#include <folly/AtomicIntrusiveLinkedList.h>
+#include <folly/CPortability.h>
#include <folly/Executor.h>
#include <folly/IntrusiveList.h>
#include <folly/Likely.h>
std::unique_ptr<LoopController> loopController,
Options options = Options());
- ~FiberManager();
+ ~FiberManager() override;
/**
* Controller access.
/**
* 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.
T& local();
template <typename T>
- static T& localThread();
+ FOLLY_EXPORT static T& localThread();
/**
* @return How many fiber objects (and stacks) has this manager allocated.
template <typename F>
RemoteTask(F&& f, const Fiber::LocalData& localData_)
: func(std::forward<F>(f)),
- localData(folly::make_unique<Fiber::LocalData>(localData_)),
+ localData(std::make_unique<Fiber::LocalData>(localData_)),
rcontext(RequestContext::saveContext()) {}
folly::Function<void()> func;
std::unique_ptr<Fiber::LocalData> localData;
AtomicIntrusiveLinkedListHook<RemoteTask> nextRemoteTask;
};
- intptr_t activateFiber(Fiber* fiber);
- intptr_t deactivateFiber(Fiber* fiber);
+ void activateFiber(Fiber* fiber);
+ void deactivateFiber(Fiber* fiber);
typedef folly::IntrusiveList<Fiber, &Fiber::listHook_> FiberTailQueue;
typedef folly::IntrusiveList<Fiber, &Fiber::globalListHook_>
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 */
*/
size_t maxFibersActiveLastPeriod_{0};
- FContext::ContextStruct mainContext_; /**< stores loop function context */
-
std::unique_ptr<LoopController> loopController_;
bool isLoopScheduled_{false}; /**< was the ready loop scheduled to run? */
void* fakeStack,
const void** saveStackBase,
size_t* saveStackSize);
+ void freeFakeStack(void* fakeStack);
void unpoisonFiberStack(const Fiber* fiber);
#endif // FOLLY_SANITIZE_ADDRESS