diff OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h @ 5452:8345267e8de5

Added OrthancPluginSetCurrentThreadName() in the plugin SDK
author Alain Mazy <am@osimis.io>
date Tue, 05 Dec 2023 17:22:36 +0100
parents 59e3b6f8c5be
children 38f1d06875ad 2c23bb7d50ce
line wrap: on
line diff
--- a/OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h	Tue Dec 05 16:28:16 2023 +0100
+++ b/OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h	Tue Dec 05 17:22:36 2023 +0100
@@ -449,6 +449,8 @@
     _OrthancPluginService_CreateDicom2 = 41,         /* New in Orthanc 1.9.0 */
     _OrthancPluginService_GetDatabaseServerIdentifier = 42,         /* New in Orthanc 1.11.1 */
     _OrthancPluginService_SetMetricsIntegerValue = 43,              /* New in Orthanc 1.12.1 */
+    _OrthancPluginService_SetCurrentThreadName = 44,                /* New in Orthanc 1.12.2 */
+
 
     /* Registration of callbacks */
     _OrthancPluginService_RegisterRestCallback = 1000,
@@ -9356,6 +9358,25 @@
   }
 
 
+/**
+   * @brief Sets the name of the current thread
+   *
+   * This function sets the name of the thread that is calling it.
+   * This name is used in the logs.  This function shall be called only from threads that
+   * the plugin has created itself.
+   * 
+   * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
+   * @param threadName The name of the current thread.  A Thread name can not be larger than 16 characters.
+   * @return 0 if success, other value if error.
+   * @ingroup Toolbox
+   **/
+  ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSetCurrentThreadName(
+    OrthancPluginContext*                        context,
+    const char*                                  threadName)
+  {
+    return context->InvokeService(context, _OrthancPluginService_SetCurrentThreadName, threadName);
+  }
+
 #ifdef  __cplusplus
 }
 #endif