diff options
author | George Hazan <george.hazan@gmail.com> | 2013-04-14 20:48:06 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-04-14 20:48:06 +0000 |
commit | 0f99e585469002fb3b35cc00464248b5338f70e3 (patch) | |
tree | 2a41ae0379147d750c769e54edc0f9ca10e8739b /src | |
parent | 599a5983835aa52c30eec4ebcaddc13e9c84685c (diff) |
thread structure optimization
git-svn-id: http://svn.miranda-ng.org/main/trunk@4451 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_core/threads.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/mir_core/threads.cpp b/src/mir_core/threads.cpp index de8d6605d7..c4dbddd220 100644 --- a/src/mir_core/threads.cpp +++ b/src/mir_core/threads.cpp @@ -93,20 +93,22 @@ static LIST<THREAD_WAIT_ENTRY> threads(10, NumericKeySortT); struct FORK_ARG {
HANDLE hEvent;
- pThreadFunc threadcode;
- pThreadFuncEx threadcodeex;
+ union {
+ pThreadFunc threadcode;
+ pThreadFuncEx threadcodeex;
+ };
void *arg, *owner;
};
/////////////////////////////////////////////////////////////////////////////////////////
// forkthread - starts a new thread
-void __cdecl forkthread_r(void * arg)
+void __cdecl forkthread_r(void *arg)
{
- struct FORK_ARG * fa = (struct FORK_ARG *) arg;
- void (*callercode)(void*)=fa->threadcode;
- void * cookie=fa->arg;
- Thread_Push(( HINSTANCE)callercode);
+ FORK_ARG *fa = (FORK_ARG*)arg;
+ pThreadFunc callercode = fa->threadcode;
+ void *cookie = fa->arg;
+ Thread_Push((HINSTANCE)callercode);
SetEvent(fa->hEvent);
__try
{
@@ -122,12 +124,11 @@ void __cdecl forkthread_r(void * arg) MIR_CORE_DLL(UINT_PTR) forkthread( void (__cdecl *threadcode)(void*), unsigned long stacksize, void *arg)
{
- UINT_PTR rc;
- struct FORK_ARG fa;
- fa.hEvent=CreateEvent(NULL, FALSE, FALSE, NULL);
- fa.threadcode=threadcode;
- fa.arg=arg;
- rc=_beginthread(forkthread_r, stacksize, &fa);
+ FORK_ARG fa;
+ fa.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ fa.threadcode = threadcode;
+ fa.arg = arg;
+ UINT_PTR rc = _beginthread(forkthread_r, stacksize, &fa);
if ((UINT_PTR)-1L != rc)
WaitForSingleObject(fa.hEvent, INFINITE);
@@ -173,13 +174,12 @@ MIR_CORE_DLL(UINT_PTR) forkthreadex( void *arg,
unsigned *thraddr)
{
- UINT_PTR rc;
struct FORK_ARG fa = { 0 };
fa.threadcodeex = threadcode;
fa.arg = arg;
fa.owner = owner;
- fa.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- rc = _beginthreadex(sec, stacksize, forkthreadex_r, (void *)&fa, 0, thraddr);
+ fa.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ UINT_PTR rc = _beginthreadex(sec, stacksize, forkthreadex_r, (void *)&fa, 0, thraddr);
if (rc)
WaitForSingleObject(fa.hEvent, INFINITE);
|