LLVM  8.0.1
Classes | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT > Class Template Reference

Contains primitive utilities for defining, calling and handling calls to remote procedures. More...

#include "llvm/ExecutionEngine/Orc/RPCUtils.h"

Inheritance diagram for llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >:
Inheritance graph
[legend]
Collaboration diagram for llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >:
Collaboration graph
[legend]

Classes

class  CanDeserializeCheck
 
class  CanSerializeCheck
 
class  OrcRPCInvalid
 
class  OrcRPCNegotiate
 
class  OrcRPCResponse
 

Public Member Functions

 RPCEndpointBase (ChannelT &C, bool LazyAutoNegotiation)
 Construct an RPC instance on a channel. More...
 
template<typename Func >
Error negotiateFunction (bool Retry=false)
 Negotiate a function id for Func with the other end of the channel. More...
 
template<typename Func , typename HandlerT , typename... ArgTs>
Error appendCallAsync (HandlerT Handler, const ArgTs &... Args)
 Append a call Func, does not call send on the channel. More...
 
Error sendAppendedCalls ()
 
template<typename Func , typename HandlerT , typename... ArgTs>
Error callAsync (HandlerT Handler, const ArgTs &... Args)
 
Error handleOne ()
 Handle one incoming call. More...
 
void abandonPendingResponses ()
 Abandon all outstanding result handlers. More...
 
template<typename Func >
void removeHandler ()
 Remove the handler for the given function. More...
 
void clearHandlers ()
 Clear all handlers. More...
 

Static Public Member Functions

template<typename... ArgTs>
**static detail::ReadArgs< ArgTs... > readArgs (ArgTs &... Args)
 Helper for handling setter procedures - this method returns a functor that sets the variables referred to by Args... More...
 

Protected Types

using WrappedHandlerFn = std::function< Error(ChannelT &, SequenceNumberT)>
 

Protected Member Functions

FunctionIdT getInvalidFunctionId () const
 
template<typename Func , typename HandlerT >
void addHandlerImpl (HandlerT Handler)
 Add the given handler to the handler map and make it available for autonegotiation and execution. More...
 
template<typename Func , typename HandlerT >
void addAsyncHandlerImpl (HandlerT Handler)
 
Error handleResponse (SequenceNumberT SeqNo)
 
FunctionIdT handleNegotiate (const std::string &Name)
 
template<typename Func >
Expected< FunctionIdT > getRemoteFunctionId (bool NegotiateIfNotInMap, bool NegotiateIfInvalid)
 
template<typename Func , typename HandlerT >
WrappedHandlerFn wrapHandler (HandlerT Handler)
 
template<typename Func , typename HandlerT >
WrappedHandlerFn wrapAsyncHandler (HandlerT Handler)
 

Protected Attributes

ChannelT & C
 
bool LazyAutoNegotiation
 
RPCFunctionIdAllocator< FunctionIdT > FnIdAllocator
 
FunctionIdT ResponseId
 
std::map< std::string, FunctionIdT > LocalFunctionIds
 
std::map< const char *, FunctionIdT > RemoteFunctionIds
 
std::map< FunctionIdT, WrappedHandlerFnHandlers
 
std::mutex ResponsesMutex
 
detail::SequenceNumberManager< SequenceNumberT > SequenceNumberMgr
 
std::map< SequenceNumberT, std::unique_ptr< detail::ResponseHandler< ChannelT > > > PendingResponses
 

Detailed Description

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
class llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >

Contains primitive utilities for defining, calling and handling calls to remote procedures.

ChannelT is a bidirectional stream conforming to the RPCChannel interface (see RPCChannel.h), FunctionIdT is a procedure identifier type that must be serializable on ChannelT, and SequenceNumberT is an integral type that will be used to number in-flight function calls.

These utilities support the construction of very primitive RPC utilities. Their intent is to ensure correct serialization and deserialization of procedure arguments, and to keep the client and server's view of the API in sync.

Definition at line 940 of file RPCUtils.h.

Member Typedef Documentation

◆ WrappedHandlerFn

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
using llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::WrappedHandlerFn = std::function<Error(ChannelT &, SequenceNumberT)>
protected

Definition at line 1260 of file RPCUtils.h.

Constructor & Destructor Documentation

◆ RPCEndpointBase()

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::RPCEndpointBase ( ChannelT &  C,
bool  LazyAutoNegotiation 
)
inline

Construct an RPC instance on a channel.

Definition at line 985 of file RPCUtils.h.

Member Function Documentation

◆ abandonPendingResponses()

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
void llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::abandonPendingResponses ( )
inline

Abandon all outstanding result handlers.

This will call all currently registered result handlers to receive an "abandoned" error as their argument. This is used internally by the RPC in error situations, but can also be called directly by clients who are disconnecting from the remote and don't or can't expect responses to their outstanding calls. (Especially for outstanding blocking calls, calling this function may be necessary to avoid dead threads).

Definition at line 1121 of file RPCUtils.h.

◆ addAsyncHandlerImpl()

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
template<typename Func , typename HandlerT >
void llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::addAsyncHandlerImpl ( HandlerT  Handler)
inlineprotected

Definition at line 1171 of file RPCUtils.h.

◆ addHandlerImpl()

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
template<typename Func , typename HandlerT >
void llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::addHandlerImpl ( HandlerT  Handler)
inlineprotected

Add the given handler to the handler map and make it available for autonegotiation and execution.

Definition at line 1158 of file RPCUtils.h.

◆ appendCallAsync()

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
template<typename Func , typename HandlerT , typename... ArgTs>
Error llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::appendCallAsync ( HandlerT  Handler,
const ArgTs &...  Args 
)
inline

Append a call Func, does not call send on the channel.

The first argument specifies a user-defined handler to be run when the function returns. The handler should take an Expected<Func::ReturnType>, or an Error (if Func::ReturnType is void). The handler will be called with an error if the return value is abandoned due to a channel error.

Definition at line 1011 of file RPCUtils.h.

◆ callAsync()

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
template<typename Func , typename HandlerT , typename... ArgTs>
Error llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::callAsync ( HandlerT  Handler,
const ArgTs &...  Args 
)
inline

Definition at line 1070 of file RPCUtils.h.

◆ clearHandlers()

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
void llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::clearHandlers ( )
inline

Clear all handlers.

Definition at line 1145 of file RPCUtils.h.

◆ getInvalidFunctionId()

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
FunctionIdT llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::getInvalidFunctionId ( ) const
inlineprotected

Definition at line 1151 of file RPCUtils.h.

◆ getRemoteFunctionId()

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
template<typename Func >
Expected<FunctionIdT> llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::getRemoteFunctionId ( bool  NegotiateIfNotInMap,
bool  NegotiateIfInvalid 
)
inlineprotected

Definition at line 1227 of file RPCUtils.h.

◆ handleNegotiate()

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
FunctionIdT llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::handleNegotiate ( const std::string &  Name)
inlineprotected

Definition at line 1218 of file RPCUtils.h.

◆ handleOne()

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
Error llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::handleOne ( )
inline

Handle one incoming call.

Definition at line 1077 of file RPCUtils.h.

◆ handleResponse()

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
Error llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::handleResponse ( SequenceNumberT  SeqNo)
inlineprotected

Definition at line 1185 of file RPCUtils.h.

◆ negotiateFunction()

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
template<typename Func >
Error llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::negotiateFunction ( bool  Retry = false)
inline

Negotiate a function id for Func with the other end of the channel.

Definition at line 1001 of file RPCUtils.h.

◆ readArgs()

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
template<typename... ArgTs>
* * static detail::ReadArgs<ArgTs...> llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::readArgs ( ArgTs &...  Args)
inlinestatic

Helper for handling setter procedures - this method returns a functor that sets the variables referred to by Args...

to values deserialized from the channel. E.g.

typedef Function<0, bool, int> Func1;

... bool B; int I; if (auto Err = expect<Func1>(Channel, readArgs(B, I))) /* Handle Args

Definition at line 1109 of file RPCUtils.h.

◆ removeHandler()

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
template<typename Func >
void llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::removeHandler ( )
inline

Remove the handler for the given function.

A handler must currently be registered for this function.

Definition at line 1134 of file RPCUtils.h.

◆ sendAppendedCalls()

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
Error llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::sendAppendedCalls ( )
inline

Definition at line 1067 of file RPCUtils.h.

◆ wrapAsyncHandler()

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
template<typename Func , typename HandlerT >
WrappedHandlerFn llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::wrapAsyncHandler ( HandlerT  Handler)
inlineprotected

Definition at line 1298 of file RPCUtils.h.

◆ wrapHandler()

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
template<typename Func , typename HandlerT >
WrappedHandlerFn llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::wrapHandler ( HandlerT  Handler)
inlineprotected

Definition at line 1265 of file RPCUtils.h.

Member Data Documentation

◆ C

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
ChannelT& llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::C
protected

Definition at line 1334 of file RPCUtils.h.

◆ FnIdAllocator

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
RPCFunctionIdAllocator<FunctionIdT> llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::FnIdAllocator
protected

Definition at line 1338 of file RPCUtils.h.

◆ Handlers

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
std::map<FunctionIdT, WrappedHandlerFn> llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::Handlers
protected

Definition at line 1344 of file RPCUtils.h.

◆ LazyAutoNegotiation

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
bool llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::LazyAutoNegotiation
protected

Definition at line 1336 of file RPCUtils.h.

◆ LocalFunctionIds

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
std::map<std::string, FunctionIdT> llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::LocalFunctionIds
protected

Definition at line 1341 of file RPCUtils.h.

◆ PendingResponses

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
std::map<SequenceNumberT, std::unique_ptr<detail::ResponseHandler<ChannelT> > > llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::PendingResponses
protected

Definition at line 1349 of file RPCUtils.h.

◆ RemoteFunctionIds

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
std::map<const char *, FunctionIdT> llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::RemoteFunctionIds
protected

Definition at line 1342 of file RPCUtils.h.

◆ ResponseId

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
FunctionIdT llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::ResponseId
protected

Definition at line 1340 of file RPCUtils.h.

◆ ResponsesMutex

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
std::mutex llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::ResponsesMutex
protected

Definition at line 1346 of file RPCUtils.h.

◆ SequenceNumberMgr

template<typename ImplT, typename ChannelT, typename FunctionIdT, typename SequenceNumberT>
detail::SequenceNumberManager<SequenceNumberT> llvm::orc::rpc::detail::RPCEndpointBase< ImplT, ChannelT, FunctionIdT, SequenceNumberT >::SequenceNumberMgr
protected

Definition at line 1347 of file RPCUtils.h.


The documentation for this class was generated from the following file: