2 * Copyright 2017 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/futures/Future.h>
18 #include <folly/futures/detail/Core.h>
19 #include <folly/portability/GTest.h>
21 using namespace folly;
24 static constexpr size_t lambdaBufSize = 8 * sizeof(void*);
26 typename std::aligned_storage<lambdaBufSize>::type lambdaBuf_;
27 folly::Optional<Try<Unit>> result_;
28 std::function<void(Try<Unit>&&)> callback_;
29 futures::detail::FSM<futures::detail::State> fsm_;
30 std::atomic<unsigned char> attached_;
31 std::atomic<bool> active_;
32 std::atomic<bool> interruptHandlerSet_;
33 folly::MicroSpinLock interruptLock_;
34 folly::MicroSpinLock executorLock_;
37 std::shared_ptr<RequestContext> context_;
38 std::unique_ptr<exception_wrapper> interrupt_;
39 std::function<void(exception_wrapper const&)> interruptHandler_;
41 // If this number goes down, it's fine!
42 // If it goes up, please seek professional advice ;-)
43 EXPECT_GE(sizeof(Gold), sizeof(futures::detail::Core<Unit>));