Mutex.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Mutex.h
  3. * Copyright © 2012 kbinani
  4. *
  5. * This file is part of vConnect-STAND.
  6. *
  7. * vConnect-STAND is free software; you can redistribute it and/or
  8. * modify it under the terms of the GPL License.
  9. *
  10. * vConnect-STAND is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. */
  14. #ifndef __Mutex_h__
  15. #define __Mutex_h__
  16. #ifdef _WIN32
  17. #include <windows.h>
  18. #include <process.h>
  19. #else
  20. #include <pthread.h>
  21. #include <stdlib.h>
  22. #endif
  23. namespace vconnect
  24. {
  25. class Mutex
  26. {
  27. private:
  28. #ifdef _WIN32
  29. HANDLE mutex;
  30. #else
  31. pthread_mutex_t *mutex;
  32. #endif
  33. public:
  34. /**
  35. * コンストラクタ
  36. */
  37. Mutex();
  38. /**
  39. * デストラクタ
  40. */
  41. ~Mutex();
  42. /**
  43. * ミューテックスをロックする
  44. */
  45. void lock();
  46. /**
  47. * ミューテックスのロックを解除する
  48. */
  49. void unlock();
  50. };
  51. }
  52. #endif