pthread_lock.h 758 B

1234567891011121314151617181920212223242526272829303132333435
  1. //
  2. // pthread_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__pthread_lock__
  9. #define __threadpp__pthread_lock__
  10. //extern "C"
  11. //{
  12. #include <pthread.h>
  13. //}
  14. namespace threadpp
  15. {
  16. class pthread_lock
  17. {
  18. pthread_mutex_t _mutex;
  19. pthread_cond_t _cond;
  20. void operator=(const pthread_lock& l){};
  21. pthread_lock(const pthread_lock& l){};
  22. public:
  23. pthread_lock();
  24. ~pthread_lock();
  25. void lock();
  26. void unlock();
  27. void wait();
  28. void wait(unsigned long millisecs);
  29. void notify();
  30. void notify_all();
  31. };
  32. }
  33. #include "pthread_lock.hpp"
  34. #endif /* defined(__threadpp__pthread_lock__) */