about summary refs log tree commit diff
diff options
context:
space:
mode:
authoroy <tom_adams@web.de>2011-05-02 10:18:30 -0700
committeroy <tom_adams@web.de>2011-05-02 10:18:30 -0700
commit80173447ff539e7a5a5e515cef8221707c46aa95 (patch)
treed2bd04e7284914c7012ea53c2dad22bf9419380b
parent96f94a315576e92297548c3c9620982b9a621a24 (diff)
parent0ea5641df42858833cb9c865e3dce21e8faa461d (diff)
downloadzcatch-80173447ff539e7a5a5e515cef8221707c46aa95.tar.gz
zcatch-80173447ff539e7a5a5e515cef8221707c46aa95.zip
Merge pull request #683 from heinrich5991/feature_detachthread.
adding thread_detach to system.h and system.c
-rw-r--r--src/base/system.c11
-rw-r--r--src/base/system.h10
2 files changed, 21 insertions, 0 deletions
diff --git a/src/base/system.c b/src/base/system.c
index 9cc7f690..2f4c5c7b 100644
--- a/src/base/system.c
+++ b/src/base/system.c
@@ -408,6 +408,17 @@ void thread_sleep(int milliseconds)
 #endif
 }
 
+void thread_detach(void *thread)
+{
+#if defined(CONF_FAMILY_UNIX)
+	pthread_detach((pthread_t)(thread));
+#elif defined(CONF_FAMILY_WINDOWS)
+	CloseHandle(thread);
+#else
+	#error not implemented
+#endif
+}
+
 
 
 
diff --git a/src/base/system.h b/src/base/system.h
index a486b89d..aab71bff 100644
--- a/src/base/system.h
+++ b/src/base/system.h
@@ -367,6 +367,16 @@ void thread_destroy(void *thread);
 */
 void thread_yield();
 
+/*
+	Function: thread_detach
+		Puts the thread in the detached thread, guaranteeing that
+		resources of the thread will be freed immediately when the
+		thread terminates.
+
+	Parameters:
+		thread - Thread to detach
+*/
+void thread_detach(void *thread);
 
 /* Group: Locks */
 typedef void* LOCK;