diff options
author | mataes2007 <mataes2007@e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb> | 2011-04-28 12:14:32 +0000 |
---|---|---|
committer | mataes2007 <mataes2007@e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb> | 2011-04-28 12:14:32 +0000 |
commit | bed6bee936ff79d32c08245f0fedaee9d839f76f (patch) | |
tree | fd32ed9cb9241b2c6387b87eb0412e5e5d2ff7c5 /dbeditorpp/threads.cpp | |
parent | 0a1ada17c01b0c517995b095eb43bb23c5b3c6f1 (diff) |
test rename
git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@64 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb
Diffstat (limited to 'dbeditorpp/threads.cpp')
-rw-r--r-- | dbeditorpp/threads.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/dbeditorpp/threads.cpp b/dbeditorpp/threads.cpp new file mode 100644 index 0000000..7ac144a --- /dev/null +++ b/dbeditorpp/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; +} |