Files
clang-p2996/llvm/unittests/ExecutionEngine/Orc/TaskDispatchTest.cpp
Lang Hames 1effa19de2 Re-apply "[ORC] Unify task dispatch across ExecutionSession and..." with fix.
This re-applies 6094b3b7db, which was reverted in a28557aadd due to broken
bots. As far as I can tell all failures were due to a missing #include <deque>,
which has been adedd in this commit.
2024-04-22 16:28:17 -08:00

36 lines
1.1 KiB
C++

//===----------- TaskDispatchTest.cpp - Test TaskDispatch APIs ------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "llvm/ExecutionEngine/Orc/TaskDispatch.h"
#include "gtest/gtest.h"
#include <future>
using namespace llvm;
using namespace llvm::orc;
TEST(InPlaceTaskDispatchTest, GenericNamedTask) {
auto D = std::make_unique<InPlaceTaskDispatcher>();
bool B = false;
D->dispatch(makeGenericNamedTask([&]() { B = true; }));
EXPECT_TRUE(B);
D->shutdown();
}
#if LLVM_ENABLE_THREADS
TEST(DynamicThreadPoolDispatchTest, GenericNamedTask) {
auto D = std::make_unique<DynamicThreadPoolTaskDispatcher>(std::nullopt);
std::promise<bool> P;
auto F = P.get_future();
D->dispatch(makeGenericNamedTask(
[P = std::move(P)]() mutable { P.set_value(true); }));
EXPECT_TRUE(F.get());
D->shutdown();
}
#endif