24 using namespace folly;
44 using CounterPtr = std::unique_ptr<size_t>;
46 static bool kRaiseWillThrow() {
49 static constexpr
auto kDelay() {
50 return std::chrono::milliseconds(500);
54 return std::make_unique<size_t>(0);
56 auto mkCGuard(CounterPtr&
ptr) {
58 std::this_thread::sleep_for(kDelay());
64 if (kRaiseWillThrow()) {
65 throw std::runtime_error(
"raise");
77 TEST_F(CallbackLifetimeTest, thenReturnsValue) {
83 TEST_F(CallbackLifetimeTest, thenReturnsValueThrows) {
89 TEST_F(CallbackLifetimeTest, thenReturnsFuture) {
92 .thenValue([
_ = mkCGuard(
c)](
auto&&) {
return makeFuture(); })
97 TEST_F(CallbackLifetimeTest, thenReturnsFutureThrows) {
100 .thenValue([
_ = mkCGuard(
c)](
auto&&) {
return raiseFut(); })
105 TEST_F(CallbackLifetimeTest, onErrorTakesExnReturnsValueMatch) {
109 .onError([
_ = mkCGuard(
c)](std::exception&) {})
114 TEST_F(CallbackLifetimeTest, onErrorTakesExnReturnsValueMatchThrows) {
118 .onError([
_ = mkCGuard(
c)](std::exception&) {
raise(); })
123 TEST_F(CallbackLifetimeTest, onErrorTakesExnReturnsValueWrong) {
127 .onError([
_ = mkCGuard(
c)](std::logic_error&) {})
132 TEST_F(CallbackLifetimeTest, onErrorTakesExnReturnsValueWrongThrows) {
136 .onError([
_ = mkCGuard(
c)](std::logic_error&) {
raise(); })
141 TEST_F(CallbackLifetimeTest, onErrorTakesExnReturnsFutureMatch) {
145 .onError([
_ = mkCGuard(
c)](std::exception&) {
return makeFuture(); })
150 TEST_F(CallbackLifetimeTest, onErrorTakesExnReturnsFutureMatchThrows) {
154 .onError([
_ = mkCGuard(
c)](std::exception&) {
return raiseFut(); })
159 TEST_F(CallbackLifetimeTest, onErrorTakesExnReturnsFutureWrong) {
163 .onError([
_ = mkCGuard(
c)](std::logic_error&) {
return makeFuture(); })
168 TEST_F(CallbackLifetimeTest, onErrorTakesExnReturnsFutureWrongThrows) {
172 .onError([
_ = mkCGuard(
c)](std::logic_error&) {
return raiseFut(); })
177 TEST_F(CallbackLifetimeTest, onErrorTakesWrapReturnsValue) {
186 TEST_F(CallbackLifetimeTest, onErrorTakesWrapReturnsValueThrows) {
195 TEST_F(CallbackLifetimeTest, onErrorTakesWrapReturnsFuture) {
204 TEST_F(CallbackLifetimeTest, onErrorTakesWrapReturnsFutureThrows) {
#define EXPECT_EQ(val1, val2)
—— Concurrent Priority Queue Implementation ——
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
bool wait(Waiter *waiter, bool shouldSleep, Waiter *&next)
TEST_F(AsyncSSLSocketWriteTest, write_coalescing1)
FOLLY_NODISCARD detail::ScopeGuardImplDecay< F, true > makeGuard(F &&f) noexcept(noexcept(detail::ScopeGuardImplDecay< F, true >(static_cast< F && >(f))))
auto via(Executor *x, Func &&func) -> Future< typename isFutureOrSemiFuture< decltype(std::declval< Func >()())>::Inner >
const internal::AnythingMatcher _
Future< typename std::decay< T >::type > makeFuture(T &&t)