2 * Copyright 2015 Facebook, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <folly/Executor.h>
24 * A DrivableExecutor can be driven via its drive() method
25 * Examples include EventBase (via loopOnce()) and ManualExecutor
26 * (via makeProgress()).
28 * This interface is most handy in conjunction with
29 * Future<T>::getVia(DrivableExecutor*) and
30 * Future<T>::waitVia(DrivableExecutor*)
32 * These call drive() * repeatedly until the Future is fulfilled.
33 * getVia() returns the value (or throws the exception) and waitVia() returns
34 * the same Future for chainability.
36 * These will be most helpful in tests, for instance if you need to pump a mock
37 * EventBase until Futures complete.
39 class DrivableExecutor : public virtual Executor {
41 virtual ~DrivableExecutor() = default;
43 // Make progress on this Executor's work.
44 virtual void drive() = 0;