2 * Copyright 2018-present 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.
17 #include <folly/executors/TimedDrivableExecutor.h>
19 #include <folly/futures/Future.h>
20 #include <folly/portability/GTest.h>
21 #include <folly/synchronization/Baton.h>
23 using namespace folly;
25 TEST(TimedDrivableExecutor, runIsStable) {
26 TimedDrivableExecutor x;
28 auto f1 = [&]() { count++; };
38 TEST(TimedDrivableExecutor, drainIsNotStable) {
39 TimedDrivableExecutor x;
41 auto f1 = [&]() { count++; };
51 TEST(TimedDrivableExecutor, try_drive) {
52 TimedDrivableExecutor x;
54 auto f1 = [&]() { count++; };
62 TEST(TimedDrivableExecutor, try_drive_for) {
63 TimedDrivableExecutor x;
65 auto f1 = [&]() { count++; };
66 x.try_drive_for(std::chrono::milliseconds(100));
69 x.try_drive_for(std::chrono::milliseconds(100));
73 TEST(TimedDrivableExecutor, try_drive_until) {
74 TimedDrivableExecutor x;
76 auto f1 = [&]() { count++; };
78 std::chrono::system_clock::now() + std::chrono::milliseconds(100));
82 std::chrono::system_clock::now() + std::chrono::milliseconds(100));