mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-07 07:14:56 -06:00
4.59 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
3901bf0ab8
commit
173c07e166
28
C/Threads.c
28
C/Threads.c
@@ -1,5 +1,5 @@
|
||||
/* Threads.c -- multithreading library
|
||||
2008-04-04
|
||||
2008-08-05
|
||||
Igor Pavlov
|
||||
Public domain */
|
||||
|
||||
@@ -25,9 +25,9 @@ static WRes MyCloseHandle(HANDLE *h)
|
||||
}
|
||||
|
||||
WRes Thread_Create(CThread *thread, THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE *startAddress)(void *), LPVOID parameter)
|
||||
{
|
||||
{
|
||||
unsigned threadId; /* Windows Me/98/95: threadId parameter may not be NULL in _beginthreadex/CreateThread functions */
|
||||
thread->handle =
|
||||
thread->handle =
|
||||
/* CreateThread(0, 0, startAddress, parameter, 0, &threadId); */
|
||||
(HANDLE)_beginthreadex(NULL, 0, startAddress, parameter, 0, &threadId);
|
||||
/* maybe we must use errno here, but probably GetLastError() is also OK. */
|
||||
@@ -36,14 +36,14 @@ WRes Thread_Create(CThread *thread, THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE
|
||||
|
||||
WRes WaitObject(HANDLE h)
|
||||
{
|
||||
return (WRes)WaitForSingleObject(h, INFINITE);
|
||||
return (WRes)WaitForSingleObject(h, INFINITE);
|
||||
}
|
||||
|
||||
WRes Thread_Wait(CThread *thread)
|
||||
{
|
||||
if (thread->handle == NULL)
|
||||
return 1;
|
||||
return WaitObject(thread->handle);
|
||||
return WaitObject(thread->handle);
|
||||
}
|
||||
|
||||
WRes Thread_Close(CThread *thread)
|
||||
@@ -59,12 +59,12 @@ WRes Event_Create(CEvent *p, BOOL manualReset, int initialSignaled)
|
||||
|
||||
WRes ManualResetEvent_Create(CManualResetEvent *p, int initialSignaled)
|
||||
{ return Event_Create(p, TRUE, initialSignaled); }
|
||||
WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p)
|
||||
WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p)
|
||||
{ return ManualResetEvent_Create(p, 0); }
|
||||
|
||||
WRes AutoResetEvent_Create(CAutoResetEvent *p, int initialSignaled)
|
||||
{ return Event_Create(p, FALSE, initialSignaled); }
|
||||
WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p)
|
||||
WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p)
|
||||
{ return AutoResetEvent_Create(p, 0); }
|
||||
|
||||
WRes Event_Set(CEvent *p) { return BOOLToWRes(SetEvent(p->handle)); }
|
||||
@@ -79,9 +79,9 @@ WRes Semaphore_Create(CSemaphore *p, UInt32 initiallyCount, UInt32 maxCount)
|
||||
return HandleToWRes(p->handle);
|
||||
}
|
||||
|
||||
WRes Semaphore_Release(CSemaphore *p, LONG releaseCount, LONG *previousCount)
|
||||
{
|
||||
return BOOLToWRes(ReleaseSemaphore(p->handle, releaseCount, previousCount));
|
||||
WRes Semaphore_Release(CSemaphore *p, LONG releaseCount, LONG *previousCount)
|
||||
{
|
||||
return BOOLToWRes(ReleaseSemaphore(p->handle, releaseCount, previousCount));
|
||||
}
|
||||
WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 releaseCount)
|
||||
{
|
||||
@@ -98,11 +98,11 @@ WRes Semaphore_Close(CSemaphore *p) { return MyCloseHandle(&p->handle); }
|
||||
WRes CriticalSection_Init(CCriticalSection *p)
|
||||
{
|
||||
/* InitializeCriticalSection can raise only STATUS_NO_MEMORY exception */
|
||||
__try
|
||||
{
|
||||
InitializeCriticalSection(p);
|
||||
__try
|
||||
{
|
||||
InitializeCriticalSection(p);
|
||||
/* InitializeCriticalSectionAndSpinCount(p, 0); */
|
||||
}
|
||||
}
|
||||
__except (EXCEPTION_EXECUTE_HANDLER) { return 1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user