From a142cc48d36cb9c6ab9ef8335f79fe8936c8b67b Mon Sep 17 00:00:00 2001 From: Thad House Date: Wed, 11 Nov 2015 20:50:30 -0800 Subject: [PATCH] Adds StopNotifier and StopRpcServer functions Workaround for #30. Allows libraries to shut down the secondary threads. --- include/ntcore_c.h | 10 ++++++++++ include/ntcore_cpp.h | 2 ++ ntcore.def | 2 ++ src/ntcore_c.cpp | 8 ++++++++ src/ntcore_cpp.cpp | 8 ++++++++ 5 files changed, 30 insertions(+) diff --git a/include/ntcore_c.h b/include/ntcore_c.h index 07e4c087e7..8084235358 100644 --- a/include/ntcore_c.h +++ b/include/ntcore_c.h @@ -350,6 +350,16 @@ void NT_StartClient(const char *server_name, unsigned int port); */ void NT_StopClient(void); +/** Stop Rpc Server + * Stops the Rpc server if it is running. +*/ +void NT_StopRpcServer(void); + +/** Stop Notifier + * Stops the Notifier (Entry and Connection Listener) thread if it is running. +*/ +void NT_StopNotifier(void); + /** Set Update Rate * Sets the update rate of the table * diff --git a/include/ntcore_cpp.h b/include/ntcore_cpp.h index ae9ae4c3ee..634b00059a 100644 --- a/include/ntcore_cpp.h +++ b/include/ntcore_cpp.h @@ -229,6 +229,8 @@ void StartServer(StringRef persist_filename, const char* listen_address, void StopServer(); void StartClient(const char* server_name, unsigned int port); void StopClient(); +void StopRpcServer(); +void StopNotifier(); void SetUpdateRate(double interval); std::vector GetConnections(); diff --git a/ntcore.def b/ntcore.def index 09ac8c6d9a..a0b8ffe087 100644 --- a/ntcore.def +++ b/ntcore.def @@ -74,6 +74,8 @@ NT_DisposeEntryInfoArray @76 NT_AllocateCharArray @77 NT_FreeCharArray @78 NT_NotifierDestroyed @79 +NT_StopRpcServer @80 +NT_StopNotifier @81 ; JNI functions JNI_OnLoad diff --git a/src/ntcore_c.cpp b/src/ntcore_c.cpp index 0f46a8469b..cf16fc0c01 100644 --- a/src/ntcore_c.cpp +++ b/src/ntcore_c.cpp @@ -333,6 +333,14 @@ void NT_StopClient(void) { nt::StopClient(); } +void NT_StopRpcServer(void) { + nt::StopRpcServer(); +} + +void NT_StopNotifier(void) { + nt::StopNotifier(); +} + void NT_SetUpdateRate(double interval) { nt::SetUpdateRate(interval); } diff --git a/src/ntcore_cpp.cpp b/src/ntcore_cpp.cpp index 040452ed7e..6e2c42b7d6 100644 --- a/src/ntcore_cpp.cpp +++ b/src/ntcore_cpp.cpp @@ -230,6 +230,14 @@ void StopClient() { Dispatcher::GetInstance().Stop(); } +void StopRpcServer() { + RpcServer::GetInstance().Stop(); +} + +void StopNotifier() { + Notifier::GetInstance().Stop(); +} + void SetUpdateRate(double interval) { Dispatcher::GetInstance().SetUpdateRate(interval); }