win_lock.h 777 B

12345678910111213141516171819202122232425262728293031323334353637
  1. //
  2. // win_lock.h
  3. // threadpp
  4. //
  5. // Created by Melo Yao on 1/15/15.
  6. // Copyright (c) 2015 Melo Yao. All rights reserved.
  7. //
  8. #ifndef __threadpp__win_lock__
  9. #define __threadpp__win_lock__
  10. #include <windows.h>
  11. namespace threadpp
  12. {
  13. class win_lock
  14. {
  15. CRITICAL_SECTION _mutex;
  16. CONDITION_VARIABLE _cond;
  17. volatile unsigned int _owner;
  18. volatile unsigned int _count;
  19. void operator=(const win_lock& l){};
  20. win_lock(const win_lock& l){};
  21. public:
  22. win_lock();
  23. ~win_lock();
  24. void lock();
  25. void unlock();
  26. void wait();
  27. void wait(unsigned long millisecs);
  28. void notify();
  29. void notify_all();
  30. };
  31. }
  32. #include "win_lock.hpp"
  33. #endif /* defined(__threadpp__win_lock__) */