summaryrefslogtreecommitdiff
path: root/sal/osl/w32/thread.c
diff options
context:
space:
mode:
authorOliver Braun <obr@openoffice.org>2001-06-01 14:02:14 +0000
committerOliver Braun <obr@openoffice.org>2001-06-01 14:02:14 +0000
commit76e4c65ac161691e394919602720d5e3c957f5e8 (patch)
tree94d95dc0e74bead2daf6ed52cdf62cb357d170f0 /sal/osl/w32/thread.c
parent063ca6c7371d525a5bc0d2ae7b43cbdedd2059ea (diff)
#72993# removed obsolete members
Diffstat (limited to 'sal/osl/w32/thread.c')
-rw-r--r--sal/osl/w32/thread.c54
1 files changed, 10 insertions, 44 deletions
diff --git a/sal/osl/w32/thread.c b/sal/osl/w32/thread.c
index 5b3916725651..00aea97ef553 100644
--- a/sal/osl/w32/thread.c
+++ b/sal/osl/w32/thread.c
@@ -2,9 +2,9 @@
*
* $RCSfile: thread.c,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: obr $ $Date: 2001-05-14 09:47:09 $
+ * last change: $Author: obr $ $Date: 2001-06-01 15:02:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -64,9 +64,8 @@
#include <osl/diagnose.h>
#include <osl/thread.h>
#include <rtl/alloc.h>
-#ifndef _OSL_TIME_H_
#include <osl/time.h>
-#endif
+#include <osl/interlck.h>
/*
Thread-data structure hidden behind oslThread:
@@ -75,17 +74,13 @@ typedef struct _osl_TThreadImpl
{
HANDLE m_hThread; /* OS-handle used for all thread-functions */
sal_uInt32 m_ThreadId; /* identifier for this thread */
- sal_uInt32 m_Flags;
- HANDLE m_hEvent;
- DWORD m_Timeout;
- CRITICAL_SECTION m_Mutex;
+ sal_Int32 m_nTerminationRequested;
oslWorkerFunction m_WorkerFunction;
void* m_pData;
} osl_TThreadImpl;
#define THREADIMPL_FLAGS_TERMINATE 0x0001
-#define THREADIMPL_FLAGS_SLEEP 0x0002
static sal_uInt32 __stdcall oslWorkerWrapperFunction(void* pData);
static oslThread oslCreateThread(oslWorkerFunction pWorker, void* pThreadData, sal_uInt32 nFlags);
@@ -95,7 +90,7 @@ typedef HRESULT (WINAPI *CoInitializeEx_PROC)(LPVOID pvReserved, DWORD dwCoInit)
CoInitializeEx_PROC _CoInitializeEx = osl_CoInitializeEx;
-/* implemented in localenc.c */
+/* implemented in nlsupport.c */
rtl_TextEncoding GetTextEncodingFromCodePage( UINT );
/*****************************************************************************/
@@ -139,12 +134,7 @@ static oslThread oslCreateThread(oslWorkerFunction pWorker,
pThreadImpl->m_WorkerFunction= pWorker;
pThreadImpl->m_pData= pThreadData;
-
- pThreadImpl->m_Flags = 0;
- pThreadImpl->m_hEvent = 0;
- pThreadImpl->m_Timeout = 0;
-
- InitializeCriticalSection(&pThreadImpl->m_Mutex);
+ pThreadImpl->m_nTerminationRequested= 0;
pThreadImpl->m_hThread=
(HANDLE)_beginthreadex(NULL, /* no security */
@@ -157,11 +147,6 @@ static oslThread oslCreateThread(oslWorkerFunction pWorker,
if(pThreadImpl->m_hThread == 0)
{
/* create failed */
- if (pThreadImpl->m_hEvent != 0)
- CloseHandle(pThreadImpl->m_hEvent);
-
- DeleteCriticalSection(&pThreadImpl->m_Mutex);
-
free(pThreadImpl);
return 0;
}
@@ -242,10 +227,8 @@ void SAL_CALL osl_freeThreadHandle(oslThread Thread)
return;
}
- if (pThreadImpl->m_hEvent != 0)
- CloseHandle(pThreadImpl->m_hEvent);
-
- DeleteCriticalSection(&pThreadImpl->m_Mutex);
+ /* !!!! _exitthreadex does _not_ call CloseHandle !!! */
+ CloseHandle( pThreadImpl->m_hThread );
/* free memory */
free(Thread);
@@ -450,9 +433,7 @@ void SAL_CALL osl_terminateThread(oslThread Thread)
return;
}
- EnterCriticalSection(&pThreadImpl->m_Mutex);
- pThreadImpl->m_Flags |= THREADIMPL_FLAGS_TERMINATE;
- LeaveCriticalSection(&pThreadImpl->m_Mutex);
+ osl_incrementInterlockedCount(&pThreadImpl->m_nTerminationRequested);
}
@@ -472,22 +453,7 @@ sal_Bool SAL_CALL osl_scheduleThread(oslThread Thread)
return sal_False;
}
- if (pThreadImpl->m_Flags & THREADIMPL_FLAGS_SLEEP)
- {
- OSL_ASSERT (pThreadImpl->m_hEvent != 0);
-
- WaitForSingleObject(pThreadImpl->m_hEvent, pThreadImpl->m_Timeout);
-
- EnterCriticalSection(&pThreadImpl->m_Mutex);
-
- pThreadImpl->m_Timeout = 0;
-
- pThreadImpl->m_Flags &= ~THREADIMPL_FLAGS_SLEEP;
-
- LeaveCriticalSection(&pThreadImpl->m_Mutex);
- }
-
- return ((pThreadImpl->m_Flags & THREADIMPL_FLAGS_TERMINATE) == 0);
+ return (0 == pThreadImpl->m_nTerminationRequested);
}
/*****************************************************************************/