Derecho  0.9
Distributed systems toolkit for RDMA
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> > Struct Template Reference

Provides functions to implement RPC sends for function calls to a single function, identified by its compile-time "tag" or ID. More...

#include <remote_invocable.hpp>

Collaboration diagram for derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >:
Collaboration graph
[legend]

Classes

struct  send_return
 Return type for the send function. More...
 

Public Types

using remote_function_type = std::function< Ret(Args...)>
 
using lock_t = std::unique_lock< std::mutex >
 
using barray = char *
 
using cbarray = const char *
 

Public Member Functions

Ret * returnRet ()
 
RemoteInvokerget_invoker (std::integral_constant< FunctionTag, Tag > const *const, const Args &...)
 
auto serialize_one (barray)
 
template<typename A , typename... Rest>
auto serialize_one (barray v, const A &a, const Rest &... rest)
 
auto serialize_all (barray v, const Args &... args)
 
send_return send (const std::function< char *(int)> &out_alloc, const std::decay_t< Args > &... remote_args)
 Called to construct an RPC message to send that will invoke the remote- invocable function targeted by this RemoteInvoker. More...
 
template<typename definitely_char >
recv_ret receive_response (std::false_type *, mutils::DeserializationManager *dsm, const node_id_t &nid, const char *response, const std::function< definitely_char *(int)> &)
 Specialization of receive_response for non-void functions. More...
 
recv_ret receive_response (std::true_type *, mutils::DeserializationManager *, const node_id_t &nid, const char *response, const std::function< char *(int)> &)
 Specialization of receive_response for void functions (which don't expect any response). More...
 
recv_ret receive_response (mutils::RemoteDeserialization_v *rdv, const node_id_t &nid, const char *response, const std::function< char *(int)> &f)
 Entry point for responses; called when a message is received that contains a response to this RemoteInvocable function's RPC call. More...
 
void fulfill_pending_results_vector (long int invocation_id, const node_list_t &who)
 Populates the pending-results map of a particular invocation of the remote-invocable function, given the list of nodes that will be contacted to call the function. More...
 
 RemoteInvoker (uint32_t class_id, uint32_t instance_id, std::map< Opcode, receive_fun_t > &receivers)
 Constructs a RemoteInvoker that provides RPC call marshalling and response-handling for a specific function tag and function type (the one specified in the class's template parameters). More...
 

Public Attributes

const Opcode invoke_opcode
 
const Opcode reply_opcode
 
PendingResults< Ret > results_vector [MAX_CONCURRENT_RPCS_PER_INVOKER]
 
std::atomic< unsigned short > invocation_id_sequencer
 

Detailed Description

template<FunctionTag Tag, typename Ret, typename... Args>
struct derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >

Provides functions to implement RPC sends for function calls to a single function, identified by its compile-time "tag" or ID.

Many versions of this class will be extended by a single RemoteInvocableClass; each specific instance of this class provides a mechanism for communicating with remote sites that handles one particular function.

Template Parameters
tagThe compile-time ID value associated with this function
RetThe function's return type
ArgsThe function's argument types

Definition at line 47 of file remote_invocable.hpp.


Class Documentation

◆ derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >::send_return

struct derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >::send_return

template<FunctionTag Tag, typename Ret, typename... Args>
struct derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >::send_return

Return type for the send function.

Contains the RPC-invoking message (in a buffer of size "size"), a set of futures for the results, and a set of promises for the results.

Definition at line 100 of file remote_invocable.hpp.

Class Members
char * buf
PendingResults< Ret > & pending
QueryResults< Ret > results
size_t size

Member Typedef Documentation

◆ barray

template<FunctionTag Tag, typename Ret , typename... Args>
using derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >::barray = char*

Definition at line 80 of file remote_invocable.hpp.

◆ cbarray

template<FunctionTag Tag, typename Ret , typename... Args>
using derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >::cbarray = const char*

Definition at line 81 of file remote_invocable.hpp.

◆ lock_t

template<FunctionTag Tag, typename Ret , typename... Args>
using derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >::lock_t = std::unique_lock<std::mutex>

Definition at line 69 of file remote_invocable.hpp.

◆ remote_function_type

template<FunctionTag Tag, typename Ret , typename... Args>
using derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >::remote_function_type = std::function<Ret(Args...)>

Definition at line 48 of file remote_invocable.hpp.

Constructor & Destructor Documentation

◆ RemoteInvoker()

template<FunctionTag Tag, typename Ret , typename... Args>
derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >::RemoteInvoker ( uint32_t  class_id,
uint32_t  instance_id,
std::map< Opcode, receive_fun_t > &  receivers 
)
inline

Constructs a RemoteInvoker that provides RPC call marshalling and response-handling for a specific function tag and function type (the one specified in the class's template parameters).

Registers a function to handle responses for this RPC call in the given "receivers" map. (The actual function implementation is not needed, since only the remote side needs to know how to implement the RPC function.)

Parameters
receiversA map from RPC message opcodes to handler functions, which this RemoteInvoker should add its functions to.

Definition at line 245 of file remote_invocable.hpp.

Member Function Documentation

◆ fulfill_pending_results_vector()

template<FunctionTag Tag, typename Ret , typename... Args>
void derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >::fulfill_pending_results_vector ( long int  invocation_id,
const node_list_t who 
)
inline

Populates the pending-results map of a particular invocation of the remote-invocable function, given the list of nodes that will be contacted to call the function.

Parameters
invocation_idThe ID referring to a particular invocation of the function
whoThe list of nodes that will service this RPC call

Definition at line 228 of file remote_invocable.hpp.

◆ get_invoker()

template<FunctionTag Tag, typename Ret , typename... Args>
RemoteInvoker& derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >::get_invoker ( std::integral_constant< FunctionTag, Tag > const *  const,
const Args &  ... 
)
inline

Definition at line 74 of file remote_invocable.hpp.

◆ receive_response() [1/3]

template<FunctionTag Tag, typename Ret , typename... Args>
template<typename definitely_char >
recv_ret derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >::receive_response ( std::false_type *  ,
mutils::DeserializationManager dsm,
const node_id_t nid,
const char *  response,
const std::function< definitely_char *(int)> &   
)
inline

Specialization of receive_response for non-void functions.

Stores the response in the results map, or stores the exception if there was an exception.

Returns
An empty recv_ret, since there is no response to a response

Definition at line 147 of file remote_invocable.hpp.

◆ receive_response() [2/3]

template<FunctionTag Tag, typename Ret , typename... Args>
recv_ret derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >::receive_response ( std::true_type *  ,
mutils::DeserializationManager ,
const node_id_t nid,
const char *  response,
const std::function< char *(int)> &   
)
inline

Specialization of receive_response for void functions (which don't expect any response).

Definition at line 195 of file remote_invocable.hpp.

◆ receive_response() [3/3]

template<FunctionTag Tag, typename Ret , typename... Args>
recv_ret derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >::receive_response ( mutils::RemoteDeserialization_v rdv,
const node_id_t nid,
const char *  response,
const std::function< char *(int)> &  f 
)
inline

Entry point for responses; called when a message is received that contains a response to this RemoteInvocable function's RPC call.

Parameters
dsm
nidThe ID of the node that sent the response
responseThe byte buffer containing the response message
f
Returns
A recv_ret containing nothing of value.

Definition at line 212 of file remote_invocable.hpp.

◆ returnRet()

template<FunctionTag Tag, typename Ret , typename... Args>
Ret* derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >::returnRet ( )
inline

Definition at line 52 of file remote_invocable.hpp.

◆ send()

template<FunctionTag Tag, typename Ret , typename... Args>
send_return derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >::send ( const std::function< char *(int)> &  out_alloc,
const std::decay_t< Args > &...  remote_args 
)
inline

Called to construct an RPC message to send that will invoke the remote- invocable function targeted by this RemoteInvoker.

Parameters
out_allocA function that can allocate buffers, which will be used to store the constructed message
aThe arguments to be used when calling the remote-invocable function

Definition at line 114 of file remote_invocable.hpp.

◆ serialize_all()

template<FunctionTag Tag, typename Ret , typename... Args>
auto derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >::serialize_all ( barray  v,
const Args &...  args 
)
inline

Definition at line 91 of file remote_invocable.hpp.

◆ serialize_one() [1/2]

template<FunctionTag Tag, typename Ret , typename... Args>
auto derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >::serialize_one ( barray  )
inline

Definition at line 83 of file remote_invocable.hpp.

◆ serialize_one() [2/2]

template<FunctionTag Tag, typename Ret , typename... Args>
template<typename A , typename... Rest>
auto derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >::serialize_one ( barray  v,
const A &  a,
const Rest &...  rest 
)
inline

Definition at line 86 of file remote_invocable.hpp.

Member Data Documentation

◆ invocation_id_sequencer

template<FunctionTag Tag, typename Ret , typename... Args>
std::atomic<unsigned short> derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >::invocation_id_sequencer

Definition at line 67 of file remote_invocable.hpp.

◆ invoke_opcode

template<FunctionTag Tag, typename Ret , typename... Args>
const Opcode derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >::invoke_opcode

Definition at line 49 of file remote_invocable.hpp.

◆ reply_opcode

template<FunctionTag Tag, typename Ret , typename... Args>
const Opcode derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >::reply_opcode

Definition at line 50 of file remote_invocable.hpp.

◆ results_vector

template<FunctionTag Tag, typename Ret , typename... Args>
PendingResults<Ret> derecho::rpc::RemoteInvoker< Tag, std::function< Ret(Args...)> >::results_vector[MAX_CONCURRENT_RPCS_PER_INVOKER]

Definition at line 66 of file remote_invocable.hpp.


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