Change ThreadManager interface to Executor

Summary:
Change ThreadManager interface to more generic Executor interface.  Specific example of supporting fibers.  This diff would replace D1967655

Test Plan: added several unittests

Reviewed By: alandau@fb.com

Subscribers: doug, alandau, bmatheny, mshneer, folly-diffs@, jsedgwick, yfeldblum, chalfant, alikhtarov, andrii, yitingli

FB internal diff: D1994663

Signature: t1:1994663:1429640509:d729ce6f020563b680d1d549f9aa273c739eb925
This commit is contained in:
Dave Watson
2015-04-27 16:53:09 -07:00
committed by Alecs King
parent 2aed11df40
commit c1ad75447b
+7 -1
View File
@@ -24,6 +24,7 @@
#include <vector>
#include <folly/AtomicLinkedList.h>
#include <folly/Executor.h>
#include <folly/Likely.h>
#include <folly/IntrusiveList.h>
#include <folly/futures/Try.h>
@@ -57,7 +58,7 @@ class LocalType {
* call. This will pause execution of this task and it will be resumed only
* when it is unblocked (via setData()).
*/
class FiberManager {
class FiberManager : public ::folly::Executor {
public:
struct Options {
#ifdef FOLLY_SANITIZE_ADDRESS
@@ -170,6 +171,11 @@ class FiberManager {
template <typename F>
void addTaskRemote(F&& func);
// Executor interface calls addTaskRemote
void add(std::function<void()> f) {
addTaskRemote(std::move(f));
}
/**
* Add a new task. When the task is complete, execute finally(Try<Result>&&)
* on the main context.