8 #ifndef NT_RPCSERVER_H_
9 #define NT_RPCSERVER_H_
12 #include <condition_variable>
17 #include "llvm/DenseMap.h"
18 #include "atomic_static.h"
20 #include "ntcore_cpp.h"
21 #include "SafeThread.h"
26 friend class RpcServerTest;
34 typedef std::function<void(std::shared_ptr<Message>)> SendMsgFunc;
39 void SetOnStart(std::function<
void()> on_start) { m_on_start = on_start; }
40 void SetOnExit(std::function<
void()> on_exit) { m_on_exit = on_exit; }
42 void ProcessRpc(
StringRef name, std::shared_ptr<Message> msg,
43 RpcCallback func,
unsigned int conn_id,
44 SendMsgFunc send_response);
46 bool PollRpc(
bool blocking,
RpcCallInfo* call_info);
47 void PostRpcResponse(
unsigned int rpc_id,
unsigned int call_uid,
57 RpcCall(
StringRef name_, std::shared_ptr<Message> msg_, RpcCallback func_,
58 unsigned int conn_id_, SendMsgFunc send_response_)
63 send_response(send_response_) {}
66 std::shared_ptr<Message> msg;
69 SendMsgFunc send_response;
74 std::queue<RpcCall> m_poll_queue;
78 std::condition_variable m_poll_cond;
80 std::atomic_bool m_terminating;
82 std::function<void()> m_on_start;
83 std::function<void()> m_on_exit;
90 #endif // NT_RPCSERVER_H_
NetworkTables RPC Call Data.
Definition: ntcore_cpp.h:79
Definition: DenseMap.h:539
Definition: RpcServer.cpp:18
Definition: RpcServer.h:25
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:39