|
libcmutils 0.6.5
Multi-platform C99 utility library
|
Data Structures | |
| struct | CMUTIL_Cond |
| Platform independent condition definition for concurrency control. More... | |
| struct | CMUTIL_Mutex |
| Platform independent mutex implementation. More... | |
| struct | CMUTIL_Thread |
| Platform independent thread object. More... | |
| struct | CMUTIL_ThreadPool |
| A threadpool object. More... | |
| struct | CMUTIL_Semaphore |
| Platform independent semaphore object. More... | |
| struct | CMUTIL_RWLock |
| Platform independent read/write lock object. More... | |
Macros | |
| #define | CMSync(a, ...) |
| Synchronized block macro. | |
Functions | |
| CMUTIL_Cond * | CMUTIL_CondCreate (CMBool manual_reset) |
| Creates a condition object. | |
| CMUTIL_Mutex * | CMUTIL_MutexCreate (void) |
| Creates a mutex object. | |
| CMUTIL_Thread * | CMUTIL_ThreadCreate (void *(*proc)(void *), void *udata, const char *name) |
| Creates a thread object. | |
| uint32_t | CMUTIL_ThreadSelfId (void) |
| Get the ID of the current thread. This id is not system thread id, just an internal thread index. | |
| CMUTIL_Thread * | CMUTIL_ThreadSelf (void) |
| Get the current thread context. | |
| uint64_t | CMUTIL_ThreadSystemSelfId (void) |
| Get system dependent thread id. | |
| CMUTIL_ThreadPool * | CMUTIL_ThreadPoolCreate (int pool_size, const char *name) |
| Creates a new threadpool object. | |
| CMUTIL_Semaphore * | CMUTIL_SemaphoreCreate (int initcnt) |
| Creates a semaphore object. | |
| CMUTIL_RWLock * | CMUTIL_RWLockCreate (void) |
| Create a read-write lock object. | |
| #define CMSync | ( | a, | |
| ... | |||
| ) |
Synchronized block macro.
This macro will lock the given mutex object, execute given statements, and unlock the given mutex object.
Note that do not use 'return', 'break', 'continue' or "goto" statements inside synchronized block, because these statements will bypass unlocking mutex operation, which will cause deadlock.
| a | Mutex object to be locked. |
| ... | Statements to be executed in synchronized block. |
| CMUTIL_Cond * CMUTIL_CondCreate | ( | CMBool | manual_reset | ) |
Creates a condition object.
Creates a manual or auto-resetting condition object.
| manual_reset | If this parameter is CMTrue, the function creates a manual-reset condition object, which requires the use of the Reset method to set the event state to nonsignaled. If this parameter is CMFalse, the function creates an auto-reset condition object, and the system automatically resets the event state to nonsignaled after a single waiting thread has been released. |
| CMUTIL_Mutex * CMUTIL_MutexCreate | ( | void | ) |
Creates a mutex object.
Any thread of the calling process can use created mutex-object in a call to lock methods. When a lock method returns, the waiting thread is released to continue its execution. This function creates a 'recursive lockable' mutex object.
| CMUTIL_Thread * CMUTIL_ThreadCreate | ( | void *(*)(void *) | proc, |
| void * | udata, | ||
| const char * | name | ||
| ) |
Creates a thread object.
Created thread does not start automatically. Call the Start method to start this thread. The returned object must be freed by calling the Join method, even if this thread is not started.
| proc | The start routine of the created thread. |
| udata | This argument is passed as the sole argument of 'proc' |
| name | Thread name, any name could be assigned and can also duplicable. But must not exceed 200 bytes. |
| uint32_t CMUTIL_ThreadSelfId | ( | void | ) |
Get the ID of the current thread. This id is not system thread id, just an internal thread index.
| CMUTIL_Thread * CMUTIL_ThreadSelf | ( | void | ) |
Get the current thread context.
| uint64_t CMUTIL_ThreadSystemSelfId | ( | void | ) |
Get system dependent thread id.
| CMUTIL_ThreadPool * CMUTIL_ThreadPoolCreate | ( | int | pool_size, |
| const char * | name | ||
| ) |
Creates a new threadpool object.
This function will create a new threadpool object with the initial size. If pool_size is zero or negative value, this threadpool object's pool size will not be fixed, will be increased one by one if needed.
| pool_size | Thread count of this threadpool if positive, otherwise this object will increase pool size automatically. |
| name | Name of this threadpool object, any name could be assigned and can also duplicable. But must not exceed 200 bytes. |
| CMUTIL_Semaphore * CMUTIL_SemaphoreCreate | ( | int | initcnt | ) |
Creates a semaphore object.
Create an in-process semaphore object.
| initcnt | Initial semaphore ownership count. |
| CMUTIL_RWLock * CMUTIL_RWLockCreate | ( | void | ) |
Create a read-write lock object.