summaryrefslogtreecommitdiff
path: root/plugins/DbEditorPP/src/threads.cpp
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2012-07-19 10:01:41 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2012-07-19 10:01:41 +0000
commit492827eb82a0f7a3cacd88c82135c54a0a08825f (patch)
treef4a5df15d3413b46fc69e0b8596b99a82494fa8e /plugins/DbEditorPP/src/threads.cpp
parent03e6d34e4f99ca3d907b328cf8afd8b7b8152b69 (diff)
DbEditorPP: changed folder structure
git-svn-id: http://svn.miranda-ng.org/main/trunk@1037 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/DbEditorPP/src/threads.cpp')
-rw-r--r--plugins/DbEditorPP/src/threads.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/plugins/DbEditorPP/src/threads.cpp b/plugins/DbEditorPP/src/threads.cpp
new file mode 100644
index 0000000000..7ac144adc4
--- /dev/null
+++ b/plugins/DbEditorPP/src/threads.cpp
@@ -0,0 +1,48 @@
+#include "headers.h"
+
+// thread stuff
+
+struct FORK_ARG {
+ HANDLE hEvent;
+ void (__cdecl *threadcode)(void*);
+ unsigned (__stdcall *threadcodeex)(void*);
+ void *arg;
+};
+
+void __cdecl forkthread_r(void *param)
+{
+ struct FORK_ARG *fa=(struct FORK_ARG*)param;
+ void (*callercode)(void*)=fa->threadcode;
+ void *arg=fa->arg;
+
+ CallService(MS_SYSTEM_THREAD_PUSH,0,0);
+
+ SetEvent(fa->hEvent);
+
+ __try {
+ callercode(arg);
+ } __finally {
+ CallService(MS_SYSTEM_THREAD_POP,0,0);
+ }
+
+ return;
+}
+
+unsigned long forkthread ( void (__cdecl *threadcode)(void*),unsigned long stacksize,void *arg)
+{
+ unsigned long rc;
+ struct FORK_ARG fa;
+
+ fa.hEvent=CreateEvent(NULL,FALSE,FALSE,NULL);
+ fa.threadcode=threadcode;
+ fa.arg=arg;
+
+ rc=_beginthread(forkthread_r,stacksize,&fa);
+
+ if ((unsigned long)-1L != rc) {
+ WaitForSingleObject(fa.hEvent,INFINITE);
+ }
+ CloseHandle(fa.hEvent);
+
+ return rc;
+}