summaryrefslogtreecommitdiffstats
path: root/ml/dlib/dlib/threads/threads_kernel_1.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-03-09 13:19:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-03-09 13:20:02 +0000
commit58daab21cd043e1dc37024a7f99b396788372918 (patch)
tree96771e43bb69f7c1c2b0b4f7374cb74d7866d0cb /ml/dlib/dlib/threads/threads_kernel_1.cpp
parentReleasing debian version 1.43.2-1. (diff)
downloadnetdata-58daab21cd043e1dc37024a7f99b396788372918.tar.xz
netdata-58daab21cd043e1dc37024a7f99b396788372918.zip
Merging upstream version 1.44.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ml/dlib/dlib/threads/threads_kernel_1.cpp')
-rw-r--r--ml/dlib/dlib/threads/threads_kernel_1.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/ml/dlib/dlib/threads/threads_kernel_1.cpp b/ml/dlib/dlib/threads/threads_kernel_1.cpp
new file mode 100644
index 000000000..cb36b8d3f
--- /dev/null
+++ b/ml/dlib/dlib/threads/threads_kernel_1.cpp
@@ -0,0 +1,83 @@
+// Copyright (C) 2003 Davis E. King (davis@dlib.net)
+// License: Boost Software License See LICENSE.txt for the full license.
+#ifndef DLIB_THREADS_KERNEL_1_CPp_
+#define DLIB_THREADS_KERNEL_1_CPp_
+
+#include "../platform.h"
+
+#ifdef WIN32
+
+#include "threads_kernel_1.h"
+
+#include <process.h>
+
+
+namespace dlib
+{
+ namespace threads_kernel_shared_helpers
+ {
+
+ // -----------------------------------------------------------------------------------
+
+ struct info
+ {
+ void* param;
+ void (*funct)(void*);
+ };
+
+ // -----------------------------------------------------------------------------------
+
+ unsigned int __stdcall thread_starter (
+ void* param
+ )
+ {
+ info* alloc_p = static_cast<info*>(param);
+ info p = *alloc_p;
+ delete alloc_p;
+
+ p.funct(p.param);
+ return 0;
+ }
+
+ // -----------------------------------------------------------------------------------
+
+ bool spawn_thread (
+ void (*funct)(void*),
+ void* param
+ )
+ {
+ info* p;
+ try { p = new info; }
+ catch (...) { return false; }
+
+ p->funct = funct;
+ p->param = param;
+
+
+ unsigned int garbage;
+
+ HANDLE thandle = (HANDLE)_beginthreadex (NULL,0,thread_starter,p,0,&garbage);
+ // make thread and add it to the pool
+
+ // return false if _beginthreadex didn't work
+ if ( thandle == 0)
+ {
+ delete p;
+ return false;
+ }
+
+ // throw away the thread handle
+ CloseHandle(thandle);
+ return true;
+ }
+
+ // -----------------------------------------------------------------------------------
+
+ }
+
+}
+
+#endif // WIN32
+
+#endif // DLIB_THREADS_KERNEL_1_CPp_
+