diff options
| author | Lang Hames <lhames@gmail.com> | 2017-09-07 21:04:00 +0000 |
|---|---|---|
| committer | Lang Hames <lhames@gmail.com> | 2017-09-07 21:04:00 +0000 |
| commit | 7b7572b8d1edeca7bfa2de0434baaec0df7f0292 (patch) | |
| tree | f2f9d9d763c4ccfb18caccccee9c4d9b22677d4e /llvm/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp | |
| parent | 5c469a3daa34faede4b43d1ef4e35d91e82c73c9 (diff) | |
| download | llvm-7b7572b8d1edeca7bfa2de0434baaec0df7f0292.zip llvm-7b7572b8d1edeca7bfa2de0434baaec0df7f0292.tar.gz llvm-7b7572b8d1edeca7bfa2de0434baaec0df7f0292.tar.bz2 | |
[ORC] Add ErrorSuccess and void specializations to AsyncHandlerTraits.
This will allow async handlers to be added that return void or Error::success().
Such handlers are expected to be common, since one of the primary uses of
addAsyncHandler is to run the body of the handler in a detached thread, in which
case the main handler returns immediately and does not need to provide an Error
value.
llvm-svn: 312746
Diffstat (limited to 'llvm/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp')
| -rw-r--r-- | llvm/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/llvm/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp index 1c9764b..7fe449b 100644 --- a/llvm/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp @@ -263,6 +263,51 @@ TEST(DummyRPC, TestCallAsyncIntInt) { ServerThread.join(); } +TEST(DummyRPC, TestAsyncVoidBoolHandler) { + auto Channels = createPairedQueueChannels(); + DummyRPCEndpoint Client(*Channels.first); + DummyRPCEndpoint Server(*Channels.second); + + std::thread ServerThread([&]() { + Server.addAsyncHandler<DummyRPCAPI::VoidBool>( + [](std::function<Error(Error)> SendResult, + bool B) { + EXPECT_EQ(B, true) << "Server void(bool) receieved unexpected result"; + cantFail(SendResult(Error::success())); + return Error::success(); + }); + + { + // Poke the server to handle the negotiate call. + auto Err = Server.handleOne(); + EXPECT_FALSE(!!Err) << "Server failed to handle call to negotiate"; + } + + { + // Poke the server to handle the VoidBool call. + auto Err = Server.handleOne(); + EXPECT_FALSE(!!Err) << "Server failed to handle call to void(bool)"; + } + }); + + { + auto Err = Client.callAsync<DummyRPCAPI::VoidBool>( + [](Error Result) { + EXPECT_FALSE(!!Result) << "Async void(bool) response handler failed"; + return Error::success(); + }, true); + EXPECT_FALSE(!!Err) << "Client.callAsync failed for void(bool)"; + } + + { + // Poke the client to process the result. + auto Err = Client.handleOne(); + EXPECT_FALSE(!!Err) << "Client failed to handle response from void(bool)"; + } + + ServerThread.join(); +} + TEST(DummyRPC, TestAsyncIntIntHandler) { auto Channels = createPairedQueueChannels(); DummyRPCEndpoint Client(*Channels.first); |
