swmutex.h 809 B

123456789101112131415161718192021222324252627282930313233
  1. /************************************************************************
  2. * AUTHOR: NiuJiuRu
  3. * FILENAME: swmutex.h
  4. * DESCRIPTION: 互斥量, 也称独占锁
  5. * NOTE: 主要用于多线程同步访问全局共享资源
  6. * HISTORY:
  7. * 1, [2010-09-06] created by NiuJiuRu
  8. ***********************************************************************/
  9. #ifndef __SWMUTEX_H__
  10. #define __SWMUTEX_H__
  11. #ifdef __cplusplus
  12. extern "C"
  13. {
  14. #endif
  15. /* 创建互斥量 */
  16. void *sw_mutex_create();
  17. /* 销毁互斥量 */
  18. void sw_mutex_destroy(void *hMutex);
  19. /* 互斥量上锁(超时设置的时间单位为: 毫秒, 并且当timeout = -1时表示无限等待) */
  20. int sw_mutex_lock(void *hMutex, int timeout);
  21. /* 互斥量解锁 */
  22. void sw_mutex_unlock(void *hMutex);
  23. #ifdef __cplusplus
  24. }
  25. #endif
  26. #endif /* __SWMUTEX_H__ */