diff src/win32/7zip/7z/C/Threads.h @ 1:f9f4f1b99eed

importing src directory
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:27 -0600
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/win32/7zip/7z/C/Threads.h	Sat Mar 03 10:31:27 2012 -0600
     1.3 @@ -0,0 +1,68 @@
     1.4 +/* Threads.h -- multithreading library
     1.5 +2008-11-22 : Igor Pavlov : Public domain */
     1.6 +
     1.7 +#ifndef __7Z_THRESDS_H
     1.8 +#define __7Z_THRESDS_H
     1.9 +
    1.10 +#include "Types.h"
    1.11 +
    1.12 +typedef struct _CThread
    1.13 +{
    1.14 +  HANDLE handle;
    1.15 +} CThread;
    1.16 +
    1.17 +#define Thread_Construct(thread) (thread)->handle = NULL
    1.18 +#define Thread_WasCreated(thread) ((thread)->handle != NULL)
    1.19 + 
    1.20 +typedef unsigned THREAD_FUNC_RET_TYPE;
    1.21 +#define THREAD_FUNC_CALL_TYPE MY_STD_CALL
    1.22 +#define THREAD_FUNC_DECL THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE
    1.23 +
    1.24 +WRes Thread_Create(CThread *thread, THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE *startAddress)(void *), LPVOID parameter);
    1.25 +WRes Thread_Wait(CThread *thread);
    1.26 +WRes Thread_Close(CThread *thread);
    1.27 +
    1.28 +typedef struct _CEvent
    1.29 +{
    1.30 +  HANDLE handle;
    1.31 +} CEvent;
    1.32 +
    1.33 +typedef CEvent CAutoResetEvent;
    1.34 +typedef CEvent CManualResetEvent;
    1.35 +
    1.36 +#define Event_Construct(event) (event)->handle = NULL
    1.37 +#define Event_IsCreated(event) ((event)->handle != NULL)
    1.38 +
    1.39 +WRes ManualResetEvent_Create(CManualResetEvent *event, int initialSignaled);
    1.40 +WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *event);
    1.41 +WRes AutoResetEvent_Create(CAutoResetEvent *event, int initialSignaled);
    1.42 +WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *event);
    1.43 +WRes Event_Set(CEvent *event);
    1.44 +WRes Event_Reset(CEvent *event);
    1.45 +WRes Event_Wait(CEvent *event);
    1.46 +WRes Event_Close(CEvent *event);
    1.47 +
    1.48 +
    1.49 +typedef struct _CSemaphore
    1.50 +{
    1.51 +  HANDLE handle;
    1.52 +} CSemaphore;
    1.53 +
    1.54 +#define Semaphore_Construct(p) (p)->handle = NULL
    1.55 +
    1.56 +WRes Semaphore_Create(CSemaphore *p, UInt32 initiallyCount, UInt32 maxCount);
    1.57 +WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num);
    1.58 +WRes Semaphore_Release1(CSemaphore *p);
    1.59 +WRes Semaphore_Wait(CSemaphore *p);
    1.60 +WRes Semaphore_Close(CSemaphore *p);
    1.61 +
    1.62 +
    1.63 +typedef CRITICAL_SECTION CCriticalSection;
    1.64 +
    1.65 +WRes CriticalSection_Init(CCriticalSection *p);
    1.66 +#define CriticalSection_Delete(p) DeleteCriticalSection(p)
    1.67 +#define CriticalSection_Enter(p) EnterCriticalSection(p)
    1.68 +#define CriticalSection_Leave(p) LeaveCriticalSection(p)
    1.69 +
    1.70 +#endif
    1.71 +