8 #ifndef NT_RPCSERVER_H_
9 #define NT_RPCSERVER_H_
12 #include <condition_variable>
17 #include "llvm/DenseMap.h"
18 #include "support/atomic_static.h"
19 #include "support/SafeThread.h"
21 #include "ntcore_cpp.h"
26 friend class RpcServerTest;
35 typedef std::function<void(std::shared_ptr<Message>)> SendMsgFunc;
40 void SetOnStart(std::function<
void()> on_start) { m_on_start = on_start; }
41 void SetOnExit(std::function<
void()> on_exit) { m_on_exit = on_exit; }
43 void ProcessRpc(StringRef name, std::shared_ptr<Message> msg,
44 RpcCallback func,
unsigned int conn_id,
47 bool PollRpc(
bool blocking,
RpcCallInfo* call_info);
48 bool PollRpc(
bool blocking,
double time_out,
RpcCallInfo* call_info);
49 void PostRpcResponse(
unsigned int rpc_id,
unsigned int call_uid,
50 llvm::StringRef result);
56 wpi::SafeThreadOwner<Thread> m_owner;
59 RpcCall(StringRef name_, std::shared_ptr<Message> msg_, RpcCallback func_,
60 unsigned int conn_id_, SendMsgFunc send_response_,
66 send_response(send_response_),
67 conn_info(conn_info_) {}
70 std::shared_ptr<Message> msg;
73 SendMsgFunc send_response;
79 std::queue<RpcCall> m_poll_queue;
80 llvm::DenseMap<std::pair<unsigned int, unsigned int>, SendMsgFunc>
83 std::condition_variable m_poll_cond;
85 std::atomic_bool m_terminating;
87 std::function<void()> m_on_start;
88 std::function<void()> m_on_exit;
95 #endif // NT_RPCSERVER_H_
NetworkTables Connection Information.
Definition: ntcore_cpp.h:43
NetworkTables RPC Call Data.
Definition: ntcore_cpp.h:79
Definition: RpcServer.cpp:18
Definition: RpcServer.h:25