LLVM 24.0.0git
SPSHandlerSpec.h
Go to the documentation of this file.
1//===- SPSHandlerSpec.h - SPS call-controller handlers ----------*- C++ -*-===//
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//===----------------------------------------------------------------------===//
8//
9// HandlerSpec binds call-controller handlers (handlers in the controller that
10// the ORC runtime calls via its call-controller mechanism) using Simple Packed
11// Serialization to decode arguments and encode results.
12//
13// Each handler's spec derives from HandlerSpec, which supplies the wire
14// signature, and adds the default tag name. It plays the same role for calls
15// from the executor to the controller that ProxySpec plays for calls from the
16// controller to the executor.
17//
18//===----------------------------------------------------------------------===//
19
20#ifndef LLVM_EXECUTIONENGINE_ORC_SPSHANDLERSPEC_H
21#define LLVM_EXECUTIONENGINE_ORC_SPSHANDLERSPEC_H
22
25
26#include <utility>
27
28namespace llvm::orc::sps {
29
30/// Base class for specs that bind handlers for calls with the SPS signature
31/// SPSSigT. Derived specs add the default tag name, e.g.:
32///
33/// \code{.cpp}
34/// struct MyHandlerSpec : sps::HandlerSpec<int32_t(int32_t, int32_t)> {
35/// static constexpr SymbolNameSpec Name =
36/// SymbolNameSpec::c("my_handler_tag");
37/// };
38/// \endcode
39///
40/// Use with bindCallControllerHandler.
41template <typename SPSSigT> class HandlerSpec {
42public:
43 /// The call's SPS signature.
44 using SPSSig = SPSSigT;
45
46 /// Wrap H as a handler for the call. H takes a sender for the call's result,
47 /// followed by the call's arguments.
48 template <typename HandlerT>
50 return [H = std::forward<HandlerT>(H)](
52 shared::WrapperFunctionBuffer ArgBytes) mutable {
54 ArgBytes.data(), ArgBytes.size(), std::move(Return), H);
55 };
56 }
57};
58
59} // namespace llvm::orc::sps
60
61#endif // LLVM_EXECUTIONENGINE_ORC_SPSHANDLERSPEC_H
#define H(x, y, z)
Definition MD5.cpp:56
unique_function< void(shared::WrapperFunctionBuffer)> CallControllerReturnFn
Function type for returning results from a call-controller handler.
Definition Core.h:1117
unique_function< void( CallControllerReturnFn, shared::WrapperFunctionBuffer)> CallControllerHandlerFn
A call-controller handler: handles calls from the executor made via the ORC runtime's call-controller...
Definition Core.h:1122
C++ wrapper function buffer: Same as CWrapperFunctionBuffer but auto-releases memory.
Base class for specs that bind handlers for calls with the SPS signature SPSSigT.
SPSSigT SPSSig
The call's SPS signature.
static ExecutionSession::CallControllerHandlerFn wrap(HandlerT &&H)
Wrap H as a handler for the call.