IR: de-duplicate two CmpInst routines (NFC) (#116866)
[llvm-project.git] / llvm / unittests / ExecutionEngine / Orc / TaskDispatchTest.cpp
blob4931fc26a417ebcf508e220c98896312bca8d01d
1 //===----------- TaskDispatchTest.cpp - Test TaskDispatch APIs ------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/ExecutionEngine/Orc/TaskDispatch.h"
10 #include "llvm/Config/llvm-config.h" // for LLVM_ENABLE_THREADS
11 #include "gtest/gtest.h"
13 #include <future>
15 using namespace llvm;
16 using namespace llvm::orc;
18 TEST(InPlaceTaskDispatchTest, GenericNamedTask) {
19 auto D = std::make_unique<InPlaceTaskDispatcher>();
20 bool B = false;
21 D->dispatch(makeGenericNamedTask([&]() { B = true; }));
22 EXPECT_TRUE(B);
23 D->shutdown();
26 #if LLVM_ENABLE_THREADS
27 TEST(DynamicThreadPoolDispatchTest, GenericNamedTask) {
28 auto D = std::make_unique<DynamicThreadPoolTaskDispatcher>(std::nullopt);
29 std::promise<bool> P;
30 auto F = P.get_future();
31 D->dispatch(makeGenericNamedTask(
32 [P = std::move(P)]() mutable { P.set_value(true); }));
33 EXPECT_TRUE(F.get());
34 D->shutdown();
36 #endif