Foxit PDF SDK

Classes | Typedefs
fx_process.h File Reference

Header file for Process & thread related definitions and classes. More...

Go to the source code of this file.

## Classes
struct | FX_HTHREAD
| Type definition of mutex handle. More...
class | CFX_RWLock
| Under non-threading mode, defines as empty implementation. More...
class | CFX_SpinLock
| Under non-threading mode, defines as empty implementation. More...
struct | FX_SYSTEMTIME
| Structure of system time. More...
struct | FX_THREADHANDLER
| Thread handler for application extension. More...
struct | FXCRT_DATETIMEZONE
| Structure for date and time. More...

## Typedefs
typedef FX_ThreadResult(WINAPI * | FX_CALLBACK_ThreadProxyProc) (FX_CALLBACK_ThreadProc threadProc, FX_LPVOID param)
| Callback function of thread proxy procedure. More...
Type for process ID
typedef FX_DWORD | FX_PROCESSID
| Process ID.

## Functions
Time
void | FX_Time_GetSystemTime (FX_SYSTEMTIME *pSystemTime)
| Retrieve the current system date and time. More...
void | FX_Time_GetLocalTime (FX_SYSTEMTIME *pSystemTime)
| Retrieve the current local date and time. More...
FX_DWORD | FX_Time_GetClock ()
| Get the clock ticks elapsed by calling process. More...
FX_DWORD | FX_Time_Sleep (FX_DWORD dwMilliseconds)
| Delay the current running for specified milliseconds. More...
void | FXCRT_GetCurrentSystemTime (FXCRT_DATETIMEZONE &dt)
| Get current system date,time and timezone information. More...
Process management
void | FX_Process_Initialize ()
| Initialize process. More...
void | FX_Process_Finalize ()
| Finalize process. More...
FX_PROCESSID | FX_Process_GetID ()
| Get the current process ID. More...
FX_LPVOID | FX_Process_GetPrivateData (FX_LPVOID key)
| Get private data in the current process. More...
void | FX_Process_SetPrivateData (FX_LPVOID key, FX_LPVOID data, PD_CALLBACK_FREEDATA callback)
| Set private data in the current process. More...
void | FX_Process_RemovePrivateData (FX_LPVOID key)
| Remove private data in the current process. More...
CFX_ProcessContext * | FX_Process_GetContext ()
| Retrieve process context. More...
Thread handler
FX_THREADHANDLER * | FX_Thread_GetHandler ()
| Get the current thread handler. More...
void | FX_Thread_SetHandler (FX_THREADHANDLER *pThreadHandler)
| Set the current thread handler. More...
Thread functions
FX_HTHREAD | FX_Thread_Create (FX_INT32 nPriority, size_t szStack, FX_CALLBACK_ThreadProc threadProc, FX_LPVOID param)
| Create a new thread. More...
void | FX_Thread_Exit ()
| Exit from the current thread. More...
FX_HTHREAD | FX_Thread_GetHandle ()
| Get the current thread handle. More...
void | FX_Thread_Yield ()
| Yield the processor to another thread. More...
FX_INT32 | FX_Thread_GetLastError ()
| Get the last error code in the current thread. More...
void | FX_Thread_SetLastError (FX_INT32 nErr)
| Set the last error code in the current thread. More...
FX_LPVOID | FX_Thread_GetPrivateData (FX_LPVOID key)
| Get private data in the current thread. More...
void | FX_Thread_SetPrivateData (FX_LPVOID key, FX_LPVOID data, PD_CALLBACK_FREEDATA callback)
| Set private data in the current thread. More...
void | FX_Thread_RemovePrivateData (FX_LPVOID key)
| Remove private data in the current thread. More...
FX_INT32 | FX_Thread_GetPriority (FX_HTHREAD hThread)
| Get thread priority. More...
void | FX_Thread_SetPriority (FX_HTHREAD hThread, FX_INT32 nPriority)
| Set thread priority. More...
FX_INT32 | FX_Thread_WaitForSingleThread (FX_HTHREAD hThread)
| Wait for termination of a single thread. More...
FX_INT32 | FX_Thread_WaitForMultipleThreads (const FX_HTHREAD *pThreads, FX_INT32 nCount)
| Wait for termination of multiple threads. More...
Context access
CFX_ThreadContext * | FX_Thread_GetContext ()
| Get the current thread context. More...
CFX_ExceptionContext * | FX_Thread_GetExceptionContext ()
| Get the current thread exception context. More...
Mutex
Note Mutex is disabled under single-thread mode or FPDFAPI_MT isn't defined, do not call the following functions under this condition. Mutex supports recursive calls in same thread.
FX_BOOL | FX_Mutex_Initialize (FX_MUTEX *pMutex)
| Initialize a mutex. More...
void | FX_Mutex_Destroy (FX_MUTEX *pMutex)
| Destroy a mutex. More...
FX_BOOL | FX_Mutex_TryLock (FX_MUTEX *pMutex)
| Try to lock a mutex. More...
void | FX_Mutex_Lock (FX_MUTEX *pMutex)
| Lock a mutex. More...
void | FX_Mutex_Unlock (FX_MUTEX *pMutex)
| Unlock a mutex. More...
Atomic Count
Note Atomic Count provides an atomic mechanism to access integer value between multiple threads. Following functions also work under single-thread mode.
FX_INT32 | FX_Atom_Add32 (volatile FX_INT32 *pAddend, FX_INT32 nIncrement)
| Increase 32-bits integer value. More...
FX_INT32 | FX_Atom_Subtract32 (volatile FX_INT32 *pAddend, FX_INT32 nDecrement)
| Decrease 32-bits integer value. More...
FX_INT64 | FX_Atom_Add64 (volatile FX_INT64 *pAddend, FX_INT64 nIncrement)
| Increase 64-bits integer value. More...
FX_INT64 | FX_Atom_Subtract64 (volatile FX_INT64 *pAddend, FX_INT64 nDecrement)
| Decrease 64-bits integer value. More...

## Flags for thread priorities
#define | FX_THREADPRIORITY_Lowest -2
| Lowest priority.
#define | FX_THREADPRIORITY_Lower -1
| Lower priority.
#define | FX_THREADPRIORITY_Normal 0
| Normal priority.
#define | FX_THREADPRIORITY_Higher 1
| Higher priority.
#define | FX_THREADPRIORITY_Highest 2
| Highest priority.
#define | THREAD_CALL_CONVENTION WINAPI
typedef DWORD | FX_ThreadResult
typedef FX_ThreadResult(WINAPI * | FX_CALLBACK_ThreadProc) (FX_LPVOID param)
| Callback function of thread procedure. More...

## Spin Lock
Note Spin Lock is disabled under single-thread mode or FPDFAPI_MT isn't defined, do not call the following functions under this condition. Spin Lock is a light-weight cocurrency mechanism for synchronizing access. Spin Lock doesn't support recursive calls in same thread.
#define | FXMT_SPLOCK_THIS
#define | FXMT_SPLOCK_OBJ(lock)
FX_BOOL | FX_SpinLock_Initialize (FX_SPINLOCK *pSpinLock)
| Initialize a spin lock. More...
void | FX_SpinLock_Destroy (FX_SPINLOCK *pSpinLock)
| Destroy a spin lock. More...
FX_BOOL | FX_SpinLock_TryLock (FX_SPINLOCK *pSpinLock)
| Try to lock a spin lock. More...
void | FX_SpinLock_Lock (FX_SPINLOCK *pSpinLock)
| Lock a spin lock. More...
void | FX_SpinLock_Unlock (FX_SPINLOCK *pSpinLock)
| Unlock a spin lock. More...
FX_BOOL | FX_SpinLock_IsLocked (FX_SPINLOCK *pSpinLock)
| Determine whether specified spin lock is locked or not. More...

## Read-Write lock
Note Read-Write Lock is disabled under single-thread mode or FPDFAPI_MT isn't defined, do not call the following functions under this condition.
#define | FXMT_RWLOCK_THIS
#define | FXMT_RWLOCK_OBJ(lock, s)
#define | FXMT_RWLOCK_DEFINEOBJ(rwLock, lock, s)
#define | FXMT_RWLOCKOBJECT_DEFINE(rwLockObj)
#define | FXMT_RWLOCKOBJECT_TRYREADLOCK(lockObj)
#define | FXMT_RWLOCKOBJECT_TRYREADLOCK_IF(lockObj)
#define | FXMT_RWLOCKOBJECT_READLOCK(lockObj)
#define | FXMT_RWLOCKOBJECT_READUNLOCK(lockObj)
#define | FXMT_RWLOCKOBJECT_TRYWRITELOCK(lockObj)
#define | FXMT_RWLOCKOBJECT_TRYWRITELOCK_IF(lockObj)
#define | FXMT_RWLOCKOBJECT_WRITELOCK(lockObj)
#define | FXMT_RWLOCKOBJECT_WRITEUNLOCK(lockObj)
FX_BOOL | FX_RWLock_Initialize (FX_RWLOCK *pRWLock)
| Initialize a read-write lock. More...
void | FX_RWLock_Destroy (FX_RWLOCK *pRWLock)
| Destroy a read-write lock. More...
FX_BOOL | FX_RWLock_TryReadLock (FX_RWLOCK *pRWLock)
| Try to lock for share read. More...
void | FX_RWLock_ReadLock (FX_RWLOCK *pRWLock)
| Lock for share read. More...
void | FX_RWLock_ReadUnlock (FX_RWLOCK *pRWLock)
| Unlock for share read. More...
FX_BOOL | FX_RWLock_TryWriteLock (FX_RWLOCK *pRWLock)
| Try to lock for exclusive write. More...
void | FX_RWLock_WriteLock (FX_RWLOCK *pRWLock)
| Lock for exclusive write. More...
void | FX_RWLock_WriteUnlock (FX_RWLOCK *pRWLock)
| Unlock for exclusive write. More...

## Detailed Description

Header file for Process & thread related definitions and classes.

Copyright (C) 2003-2026, Foxit Software Inc.. All Rights Reserved.

http://www.foxitsoftware.com

The following code is copyrighted and is the proprietary of Foxit Software Inc.. It is not allowed to distribute any parts of Foxit PDF SDK to third party or public without permission unless an agreement is signed between Foxit Software Inc. and customers to explicitly grant customers permissions.

## Function Documentation

## ◆ FX_Atom_Add32()

FX_INT32 FX_Atom_Add32 | ( | volatile FX_INT32 * | pAddend,
|  | FX_INT32 | nIncrement
| ) |  |

Increase 32-bits integer value.

Parameters

  [in,out] | pAddend | Pointer to 32-bits integer to increase value.
  [in] | nIncrement | Increment value to be added to pAddend.

Returns
  New increment value.

## ◆ FX_Atom_Add64()

FX_INT64 FX_Atom_Add64 | ( | volatile FX_INT64 * | pAddend,
|  | FX_INT64 | nIncrement
| ) |  |

Increase 64-bits integer value.

Parameters

  [in,out] | pAddend | Pointer to 64-bits integer to increase value.
  [in] | nIncrement | Increment value to be added to pAddend.

Returns
  New increment value.

## ◆ FX_Atom_Subtract32()

FX_INT32 FX_Atom_Subtract32 | ( | volatile FX_INT32 * | pAddend,
|  | FX_INT32 | nDecrement
| ) |  |

Decrease 32-bits integer value.

Parameters

  [in,out] | pAddend | Pointer to 32-bits integer to decrease value.
  [in] | nDecrement | Decrement value to be subtracted from pAddend.

Returns
  New decrement value.

## ◆ FX_Atom_Subtract64()

FX_INT64 FX_Atom_Subtract64 | ( | volatile FX_INT64 * | pAddend,
|  | FX_INT64 | nDecrement
| ) |  |

Decrease 64-bits integer value.

Parameters

  [in,out] | pAddend | Pointer to 64-bits integer to decrease value.
  [in] | nDecrement | Decrement value to be subtracted from pAddend.

Returns
  New decrement value.

## ◆ FX_Mutex_Destroy()

void FX_Mutex_Destroy | ( | FX_MUTEX * | pMutex | ) |

Destroy a mutex.

Parameters

  [in] | pMutex | Pointer to a mutex to be destroyed. Must be not a NULL pointer.

Returns
  None.

## ◆ FX_Mutex_Initialize()

FX_BOOL FX_Mutex_Initialize | ( | FX_MUTEX * | pMutex | ) |

Initialize a mutex.

Parameters

  [in] | pMutex | Pointer to a mutex which need to be initialized. Must be not a NULL pointer.

Returns
  true means success, while false means failure.

## ◆ FX_Mutex_Lock()

void FX_Mutex_Lock | ( | FX_MUTEX * | pMutex | ) |

Lock a mutex.

Parameters

  [in] | pMutex | Pointer to a mutex. Must be not a NULL pointer.

Returns
  None.

Note
  If another thread owns the mutex when calls this function, this function won't return until the current thread obtains the ownership of the mutex.

## ◆ FX_Mutex_TryLock()

FX_BOOL FX_Mutex_TryLock | ( | FX_MUTEX * | pMutex | ) |

Try to lock a mutex.

Parameters

  [in] | pMutex | Pointer to a mutex. Must be not a NULL pointer.

Returns
  true means the given mutex object is locked successfully or the current thread already owns the mutex, while false means another thread owns the mutex already or other error occurs.

## ◆ FX_Mutex_Unlock()

void FX_Mutex_Unlock | ( | FX_MUTEX * | pMutex | ) |

Unlock a mutex.

Parameters

  [in] | pMutex | Pointer to a mutex. Must be not a NULL pointer.

Returns
  None.

## ◆ FX_RWLock_Destroy()

void FX_RWLock_Destroy | ( | FX_RWLOCK * | pRWLock | ) |

Destroy a read-write lock.

Parameters

  [in] | pRWLock | Pointer to a read-write lock to be destroyed. Must be not a NULL pointer.

Returns
  None.

## ◆ FX_RWLock_Initialize()

FX_BOOL FX_RWLock_Initialize | ( | FX_RWLOCK * | pRWLock | ) |

Initialize a read-write lock.

Parameters

  [in] | pRWLock | Pointer to a read-write lock which need to be initialized. Must be not a NULL pointer.

Returns
  true means success, while false means failure.

## ◆ FX_RWLock_ReadLock()

void FX_RWLock_ReadLock | ( | FX_RWLOCK * | pRWLock | ) |

Lock for share read.

Parameters

  [in] | pRWLock | Pointer to a read-write lock. Must be not a NULL pointer.

Returns
  None.

Note
  If another thread owns the read-write lock when calls this function, this function won't return until the current thread obtains the ownership of the read-write lock.

## ◆ FX_RWLock_ReadUnlock()

void FX_RWLock_ReadUnlock | ( | FX_RWLOCK * | pRWLock | ) |

Unlock for share read.

Parameters

  [in] | pRWLock | Pointer to a read-write lock. Must be not a NULL pointer.

Returns
  None.

## ◆ FX_RWLock_TryReadLock()

FX_BOOL FX_RWLock_TryReadLock | ( | FX_RWLOCK * | pRWLock | ) |

Try to lock for share read.

Parameters

  [in] | pRWLock | Pointer to a read-write lock. Must be not a NULL pointer.

Returns
  true means the given read-write lock object is locked successfully or current thread already owns the read-write lock, false means another thread owns the read-write lock already or other error occurs.

## ◆ FX_RWLock_TryWriteLock()

FX_BOOL FX_RWLock_TryWriteLock | ( | FX_RWLOCK * | pRWLock | ) |

Try to lock for exclusive write.

Parameters

  [in] | pRWLock | Pointer to a read-write lock. Must be not a NULL pointer.

Returns
  true if the given read-write lock object is locked successfully or current thread already owns the read-write lock, false means another thread owns the read-write lock already or other error occurs.

## ◆ FX_RWLock_WriteLock()

void FX_RWLock_WriteLock | ( | FX_RWLOCK * | pRWLock | ) |

Lock for exclusive write.

Parameters

  [in] | pRWLock | Pointer to a read-write lock. Must be not a NULL pointer.

Returns
  None.

Note
  If another thread owns the read-write lock when calls this function, this function won't return until the current thread obtains the ownership of the read-write lock.

## ◆ FX_RWLock_WriteUnlock()

void FX_RWLock_WriteUnlock | ( | FX_RWLOCK * | pRWLock | ) |

Unlock for exclusive write.

Parameters

  [in] | pRWLock | Pointer to a read-write lock. Must be not a NULL pointer.

Returns
  None.

## ◆ FX_SpinLock_Destroy()

void FX_SpinLock_Destroy | ( | FX_SPINLOCK * | pSpinLock | ) |

Destroy a spin lock.

Parameters

  [in] | pSpinLock | Pointer to a spin lock to be destroyed.

Returns
  None.

## ◆ FX_SpinLock_Initialize()

FX_BOOL FX_SpinLock_Initialize | ( | FX_SPINLOCK * | pSpinLock | ) |

Initialize a spin lock.

Parameters

  [in] | pSpinLock | Pointer to a spin lock to be initialized.

Returns
  true means success, while false means failure.

## ◆ FX_SpinLock_IsLocked()

FX_BOOL FX_SpinLock_IsLocked | ( | FX_SPINLOCK * | pSpinLock | ) |

Determine whether specified spin lock is locked or not.

Parameters

  [in] | pSpinLock | Pointer to a spin lock.

Returns
  true means spin lock is locked, while false means spin lock is unlocked.

## ◆ FX_SpinLock_Lock()

void FX_SpinLock_Lock | ( | FX_SPINLOCK * | pSpinLock | ) |

Lock a spin lock.

Parameters

  [in] | pSpinLock | Pointer to a spin lock.

Returns
  None.

Note
  If another thread owns the spin lock when calls this function, this function won't return until the current thread obtains the ownership of the spin lock.

## ◆ FX_SpinLock_TryLock()

FX_BOOL FX_SpinLock_TryLock | ( | FX_SPINLOCK * | pSpinLock | ) |

Try to lock a spin lock.

Parameters

  [in] | pSpinLock | Pointer to a spin lock.

Returns
  true means the given spin lock object is locked successfully or current thread already owns the spin lock, while false means another thread owns the spin lock already or other error occurs.

## ◆ FX_SpinLock_Unlock()

void FX_SpinLock_Unlock | ( | FX_SPINLOCK * | pSpinLock | ) |

Unlock a spin lock.

Parameters

  [in] | pSpinLock | Pointer to a spin lock.

Returns
  None.

## ◆ FX_Thread_Create()

FX_HTHREAD FX_Thread_Create | ( | FX_INT32 | nPriority,
|  | size_t | szStack,
|  | FX_CALLBACK_ThreadProc | threadProc,
|  | FX_LPVOID | param
| ) |  |

Create a new thread.

Parameters

  [in] | nPriority | Thread priority.
  [in] | szStack | Stack size of thread, set to 0 for default stack size.
  [in] | threadProc | Thread callback function.
  [in] | param | Parameter passed to thread procedure.

Returns
  Thread handle. NULL means failure.

## ◆ FX_Thread_Exit()

void FX_Thread_Exit | ( |  | ) |

Exit from the current thread.

Returns
  None.

## ◆ FX_Thread_GetContext()

CFX_ThreadContext* FX_Thread_GetContext | ( |  | ) |

Get the current thread context.

Returns
  The current thread context. NULL means failure.

## ◆ FX_Thread_GetExceptionContext()

CFX_ExceptionContext* FX_Thread_GetExceptionContext | ( |  | ) |

Get the current thread exception context.

Returns
  The current thread exception context. NULL means failure.

## ◆ FX_Thread_GetHandle()

FX_HTHREAD FX_Thread_GetHandle | ( |  | ) |

Get the current thread handle.

Returns
  The current thread handle, NULL if failure.

## ◆ FX_Thread_GetHandler()

FX_THREADHANDLER* FX_Thread_GetHandler | ( |  | ) |

Get the current thread handler.

Returns
  The current thread handler. NULL means no thread handler has been set.

Note
  This function returns NULL always under single-thread mode or FPDFAPI_MT isn't defined.

## ◆ FX_Thread_GetLastError()

FX_INT32 FX_Thread_GetLastError | ( |  | ) |

Get the last error code in the current thread.

Returns
  The last error code.

## ◆ FX_Thread_GetPriority()

FX_INT32 FX_Thread_GetPriority | ( | FX_HTHREAD | hThread | ) |

Get thread priority.

Parameters

  [in] | hThread | Thread handle specifies a thread to retrieve its priority.

Returns
  Priority code of thread.

## ◆ FX_Thread_GetPrivateData()

FX_LPVOID FX_Thread_GetPrivateData | ( | FX_LPVOID | key | ) |

Get private data in the current thread.

Parameters

  [in] | key | Key value to specify private data to be retrieved.

Returns
  Pointer to private data, NULL if failure.

## ◆ FX_Thread_RemovePrivateData()

void FX_Thread_RemovePrivateData | ( | FX_LPVOID | key | ) |

Remove private data in the current thread.

Parameters

  [in] | key | Key value to specify private data to be removed.

Returns
  None.

## ◆ FX_Thread_SetHandler()

void FX_Thread_SetHandler | ( | FX_THREADHANDLER * | pThreadHandler | ) |

Set the current thread handler.

Parameters

  [in] | pThreadHandler | Pointer to external thread handler.

Returns
  None.

Note
  This function is disabled under single-thread mode or FPDFAPI_MT isn't defined.

## ◆ FX_Thread_SetLastError()

void FX_Thread_SetLastError | ( | FX_INT32 | nErr | ) |

Set the last error code in the current thread.

Parameters

  [in] | nErr | The last error code to be set.

Returns
  None.

## ◆ FX_Thread_SetPriority()

void FX_Thread_SetPriority | ( | FX_HTHREAD | hThread,
|  | FX_INT32 | nPriority
| ) |  |

Set thread priority.

Parameters

  [in] | hThread | Thread handle specifies a thread to change its priority.
  [in] | nPriority | Thread priority code.

Returns
  None.

## ◆ FX_Thread_SetPrivateData()

void FX_Thread_SetPrivateData | ( | FX_LPVOID | key,
|  | FX_LPVOID | data,
|  | PD_CALLBACK_FREEDATA | callback
| ) |  |

Set private data in the current thread.

Parameters

  [in] | key | Key value to specify private data to be set.
  [in] | data | Pointer to private data.
  [in] | callback | Callback function address which is used to free private data. Pass NULL if need no additional process to free private data.

Returns
  None.

## ◆ FX_Thread_WaitForMultipleThreads()

FX_INT32 FX_Thread_WaitForMultipleThreads | ( | const FX_HTHREAD * | pThreads,
|  | FX_INT32 | nCount
| ) |  |

Wait for termination of multiple threads.

Parameters

  [in] | pThreads | Pointer to array of thread handles.
  [in] | nCount | Number of threads in array.

Returns
  0 means all threads terminates successfully, other value means failure.

## ◆ FX_Thread_WaitForSingleThread()

FX_INT32 FX_Thread_WaitForSingleThread | ( | FX_HTHREAD | hThread | ) |

Wait for termination of a single thread.

Parameters

  [in] | hThread | Thread handle specifies a thread to wait.

Returns
  0 means thread terminates successfully, other value means failure.

## ◆ FX_Thread_Yield()

void FX_Thread_Yield | ( |  | ) |

Yield the processor to another thread.

Returns
  None.