20 #ifndef _FX_PROCESS_H_ 21 #define _FX_PROCESS_H_ 27 #if _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_LINUX_EMBEDDED_ || _FX_OS_ == _FX_ANDROID_ || _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_ 35 class CFX_ProcessContext;
36 class CFX_ThreadContext;
37 class CFX_ExceptionContext;
52 typedef struct _FX_SYSTEMTIME
95 typedef struct _FXCRT_DATETIMEZONE
150 #if _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_ 263 #define FX_THREADPRIORITY_Lowest -2 265 #define FX_THREADPRIORITY_Lower -1 267 #define FX_THREADPRIORITY_Normal 0 269 #define FX_THREADPRIORITY_Higher 1 271 #define FX_THREADPRIORITY_Highest 2 280 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 281 typedef DWORD FX_ThreadResult;
282 # define THREAD_CALL_CONVENTION WINAPI 285 # define THREAD_CALL_CONVENTION 320 typedef struct _FX_THREADHANDLER
732 #define FXMT_SPLOCK_THIS CFX_SpinLock _fx_splock((FX_SPINLOCK*)this) 737 #define FXMT_SPLOCK_OBJ(lock) CFX_SpinLock _fx_splock(lock) 743 #define FXMT_SPLOCK_THIS 744 #define FXMT_SPLOCK_OBJ(lock) 843 class CFX_RWLockObject :
public CFX_Object
876 Init(pRWLock, nStatus);
880 Init(&pRWLockObj->m_Lock, nStatus);
884 if (!m_pRWLock || !m_nStatus)
return;
937 FX_RWLOCK* m_pRWLock;
940 void Init(FX_RWLOCK* pRWLock,
FX_INT32 nStatus)
942 m_pRWLock = pRWLock, m_nStatus = nStatus;
943 if (!m_pRWLock || !m_nStatus)
return;
952 #define FXMT_RWLOCK_THIS CFX_RWLock _fx_rwlock((CFX_RWLock*)this) 954 #define FXMT_RWLOCK_OBJ(lock, s) CFX_RWLock _fx_rwlock(lock, s) 956 #define FXMT_RWLOCK_DEFINEOBJ(rwLock, lock, s) CFX_RWLock rwLock(lock, s) 959 #define FXMT_RWLOCKOBJECT_DEFINE(rwLockObj) CFX_RWLockObject rwLockObj 961 #define FXMT_RWLOCKOBJECT_TRYREADLOCK(lockObj) (lockObj)->TryReadLock() 963 #define FXMT_RWLOCKOBJECT_TRYREADLOCK_IF(lockObj) if ((lockObj)->TryReadLock()) 965 #define FXMT_RWLOCKOBJECT_READLOCK(lockObj) (lockObj)->ReadLock() 967 #define FXMT_RWLOCKOBJECT_READUNLOCK(lockObj) (lockObj)->ReadUnlock() 969 #define FXMT_RWLOCKOBJECT_TRYWRITELOCK(lockObj) (lockObj)->TryWriteLock() 971 #define FXMT_RWLOCKOBJECT_TRYWRITELOCK_IF(lockObj) if ((lockObj)->TryWriteLock()) 973 #define FXMT_RWLOCKOBJECT_WRITELOCK(lockObj) (lockObj)->WriteLock() 975 #define FXMT_RWLOCKOBJECT_WRITEUNLOCK(lockObj) (lockObj)->WriteUnlock() 980 #define FXMT_RWLOCK_THIS 981 #define FXMT_RWLOCK_OBJ(lock, s) 982 #define FXMT_RWLOCK_DEFINEOBJ(rwLock, lock, s) 984 #define FXMT_RWLOCKOBJECT_DEFINE(rwLockObj) 985 #define FXMT_RWLOCKOBJECT_TRYREADLOCK(lockObj) 986 #define FXMT_RWLOCKOBJECT_TRYREADLOCK_IF(lockObj) 987 #define FXMT_RWLOCKOBJECT_READLOCK(lockObj) 988 #define FXMT_RWLOCKOBJECT_READUNLOCK(lockObj) 989 #define FXMT_RWLOCKOBJECT_TRYWRITELOCK(lockObj) 990 #define FXMT_RWLOCKOBJECT_TRYWRITELOCK_IF(lockObj) 991 #define FXMT_RWLOCKOBJECT_WRITELOCK(lockObj) 992 #define FXMT_RWLOCKOBJECT_WRITEUNLOCK(lockObj) FX_THREADHANDLER * FX_Thread_GetHandler()
Get the current thread handler.
Under non-threading mode, defines as empty implementation.
Definition: fx_process.h:979
void FX_Thread_Yield()
Yield the processor to another thread.
FX_BOOL FX_Mutex_TryLock(FX_MUTEX *pMutex)
Try to lock a mutex.
FX_INT32 FX_Thread_WaitForMultipleThreads(const FX_HTHREAD *pThreads, FX_INT32 nCount)
Wait for termination of multiple threads.
void * FX_LPVOID
Pointer to any type.
Definition: fx_system.h:645
void FX_Time_GetLocalTime(FX_SYSTEMTIME *pSystemTime)
Retrieve the current local date and time.
FX_BOOL FX_SpinLock_Initialize(FX_SPINLOCK *pSpinLock)
Initialize a spin lock.
FX_BOOL FX_Mutex_Initialize(FX_MUTEX *pMutex)
Initialize a mutex.
void FX_Thread_SetLastError(FX_INT32 nErr)
Set the last error code in the current thread.
void FX_Thread_SetPrivateData(FX_LPVOID key, FX_LPVOID data, PD_CALLBACK_FREEDATA callback)
Set private data in the current thread.
void FX_Thread_SetPriority(FX_HTHREAD hThread, FX_INT32 nPriority)
Set thread priority.
FX_INT32 FX_Atom_Add32(volatile FX_INT32 *pAddend, FX_INT32 nIncrement)
Increase 32-bits integer value.
FX_WORD day
Day of month, from 1 to 31.
Definition: fx_process.h:102
FX_BOOL FX_RWLock_TryReadLock(FX_RWLOCK *pRWLock)
Try to lock for share read.
unsigned long FX_DWORD
32-bit unsigned integer.
Definition: fx_system.h:715
FX_INT64 FX_Atom_Add64(volatile FX_INT64 *pAddend, FX_INT64 nIncrement)
Increase 64-bits integer value.
FX_INT32 FX_Thread_GetPriority(FX_HTHREAD hThread)
Get thread priority.
FX_DWORD FX_PROCESSID
Process ID.
Definition: fx_process.h:155
CFX_ThreadContext * FX_Thread_GetContext()
Get the current thread context.
FX_INT32 FX_Atom_Subtract32(volatile FX_INT32 *pAddend, FX_INT32 nDecrement)
Decrease 32-bits integer value.
void(* PD_CALLBACK_FREEDATA)(FX_LPVOID pData)
Definition: fx_basic.h:3253
FX_BOOL FX_RWLock_Initialize(FX_RWLOCK *pRWLock)
Initialize a read-write lock.
FX_WORD milliseconds
Millisecond, from 0 to 999. PDF standard doesn't support now, you can omit this field if it is not ap...
Definition: fx_process.h:112
Thread handler for application extension.
Definition: fx_process.h:320
void FX_RWLock_ReadUnlock(FX_RWLOCK *pRWLock)
Unlock for share read.
CRITICAL_SECTION FX_MUTEX
Definition for mutex/critical section and read-write lock.
Definition: fx_system.h:1588
FX_WORD year
Year, a four-digit number, such as 2014.
Definition: fx_process.h:98
void FX_Process_Initialize()
Initialize process.
Structure for date and time.
Definition: fx_process.h:95
__int64 FX_INT64
Signed 64-bit integer.
Definition: fx_system.h:729
void FX_RWLock_Destroy(FX_RWLOCK *pRWLock)
Destroy a read-write lock.
FX_WORD second
Second, from 0 to 60. 60 for leap second.
Definition: fx_process.h:110
Under non-threading mode, defines as empty implementation.
Definition: fx_process.h:742
FX_BOOL FX_SpinLock_IsLocked(FX_SPINLOCK *pSpinLock)
Determine whether specified spin lock is locked or not.
int FX_INT32
32-bit signed integer.
Definition: fx_system.h:674
FX_INT64 FX_Atom_Subtract64(volatile FX_INT64 *pAddend, FX_INT64 nDecrement)
Decrease 64-bits integer value.
FX_PROCESSID FX_Process_GetID()
Get the current process ID.
void FX_RWLock_WriteLock(FX_RWLOCK *pRWLock)
Lock for exclusive write.
FX_LPVOID FX_Thread_GetPrivateData(FX_LPVOID key)
Get private data in the current thread.
int FX_BOOL
Boolean variable (should be TRUE or FALSE).
Definition: fx_system.h:682
void FX_Time_GetSystemTime(FX_SYSTEMTIME *pSystemTime)
Retrieve the current system date and time.
CFX_ExceptionContext * FX_Thread_GetExceptionContext()
Get the current thread exception context.
void FX_Thread_SetHandler(FX_THREADHANDLER *pThreadHandler)
Set the current thread handler.
FX_LPVOID pUserData
Pointer to user data.
Definition: fx_process.h:323
FX_WORD tzMinute
Minute of time zone, from 0 to 59.
Definition: fx_process.h:120
FX_BOOL FX_RWLock_TryWriteLock(FX_RWLOCK *pRWLock)
Try to lock for exclusive write.
void FX_Process_RemovePrivateData(FX_LPVOID key)
Remove private data in the current process.
void * FX_SPINLOCK
Definition for spinlock.
Definition: fx_system.h:1618
void FX_Mutex_Destroy(FX_MUTEX *pMutex)
Destroy a mutex.
FX_WORD hour
Hour, from 0 to 23.
Definition: fx_process.h:106
FX_LPVOID FX_Process_GetPrivateData(FX_LPVOID key)
Get private data in the current process.
FX_ThreadResult(WINAPI * FX_CALLBACK_ThreadProxyProc)(FX_CALLBACK_ThreadProc threadProc, FX_LPVOID param)
Callback function of thread proxy procedure.
Definition: fx_process.h:306
void FX_SpinLock_Destroy(FX_SPINLOCK *pSpinLock)
Destroy a spin lock.
FX_DWORD FX_Time_Sleep(FX_DWORD dwMilliseconds)
Delay the current running for specified milliseconds.
void FX_SpinLock_Lock(FX_SPINLOCK *pSpinLock)
Lock a spin lock.
void FX_Mutex_Unlock(FX_MUTEX *pMutex)
Unlock a mutex.
FX_INT32 FX_Thread_GetLastError()
Get the last error code in the current thread.
FX_WORD dayOfWeek
Day of week, from 0 to 6. PDF standard doesn't support now, you can omit this field if it is not appl...
Definition: fx_process.h:104
void FXCRT_GetCurrentSystemTime(FXCRT_DATETIMEZONE &dt)
Get current system date,time and timezone information.
FX_WORD minute
Minute, from 0 to 59.
Definition: fx_process.h:108
FX_ThreadResult(WINAPI * FX_CALLBACK_ThreadProc)(FX_LPVOID param)
Callback function of thread procedure.
Definition: fx_process.h:295
void FX_Mutex_Lock(FX_MUTEX *pMutex)
Lock a mutex.
void FX_SpinLock_Unlock(FX_SPINLOCK *pSpinLock)
Unlock a spin lock.
FX_HTHREAD FX_Thread_Create(FX_INT32 nPriority, size_t szStack, FX_CALLBACK_ThreadProc threadProc, FX_LPVOID param)
Create a new thread.
void FX_Thread_RemovePrivateData(FX_LPVOID key)
Remove private data in the current thread.
unsigned short FX_WORD
16-bit unsigned integer.
Definition: fx_system.h:668
CFX_ProcessContext * FX_Process_GetContext()
Retrieve process context.
void FX_Process_SetPrivateData(FX_LPVOID key, FX_LPVOID data, PD_CALLBACK_FREEDATA callback)
Set private data in the current process.
void FX_Process_Finalize()
Finalize process.
Header file for basic data class.
FX_BOOL FX_SpinLock_TryLock(FX_SPINLOCK *pSpinLock)
Try to lock a spin lock.
void FX_RWLock_WriteUnlock(FX_RWLOCK *pRWLock)
Unlock for exclusive write.
#define NULL
The null-pointer value.
Definition: fx_system.h:780
#define FX_DEFINEHANDLE(name)
Macro to define a handle type.
Definition: fx_system.h:760
FX_HTHREAD FX_Thread_GetHandle()
Get the current thread handle.
FX_INT32 tzHour
Hour of time zone, from -12 to 12.
Definition: fx_process.h:118
void FX_RWLock_ReadLock(FX_RWLOCK *pRWLock)
Lock for share read.
FX_INT32 FX_Thread_WaitForSingleThread(FX_HTHREAD hThread)
Wait for termination of a single thread.
void FX_Thread_Exit()
Exit from the current thread.
FX_WORD month
Month, from 1 to 12.
Definition: fx_process.h:100
Structure of system time.
Definition: fx_process.h:52
FX_DWORD FX_Time_GetClock()
Get the clock ticks elapsed by calling process.