| 123456789101112131415161718192021222324252627282930313233343536 |
- /************************************************************************
- * AUTHOR: NiuJiuRu
- * FILENAME: sw_rwlock.h
- * DESCRIPTION: 读写锁, 也称共享锁
- * NOTE: 主要用于多线程同步访问全局共享资源
- * HISTORY:
- * 1, [2013-05-30] created by NiuJiuRu
- ***********************************************************************/
- #ifndef __SWRWLOCK_H__
- #define __SWRWLOCK_H__
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- /* 创建读写锁 */
- void *sw_rwlock_create();
- /* 销毁读写锁 */
- void sw_rwlock_destroy(void *hRWLock);
- /* 读写锁上锁-读(超时设置的时间单位为: 毫秒, 并且当timeout = -1时表示无限等待) */
- int sw_rwlock_rdlock(void *hRWLock, int timeout);
- /* 读写锁上锁-写(超时设置的时间单位为: 毫秒, 并且当timeout = -1时表示无限等待) */
- int sw_rwlock_wrlock(void *hRWLock, int timeout);
- /* 读写锁解锁 */
- void sw_rwlock_unlock(void *hRWLock);
- #ifdef __cplusplus
- }
- #endif
- #endif /* __SWRWLOCK_H__ */
|