Mutex.cpp 423 B

1234567891011121314151617181920212223
  1. #include "core/thread/Mutex.hpp"
  2. #include <string.h>
  3. Core::Mutex::Mutex() : mutex() {
  4. memset(&mutex, 0, sizeof(mutex));
  5. }
  6. Core::Mutex::~Mutex() {
  7. mtx_destroy(&mutex);
  8. }
  9. cbool Core::Mutex::init() {
  10. return mtx_init(&mutex, mtx_plain) != thrd_success;
  11. }
  12. cbool Core::Mutex::lock() {
  13. return mtx_lock(&mutex) != thrd_success;
  14. }
  15. cbool Core::Mutex::unlock() {
  16. return mtx_unlock(&mutex) != thrd_success;
  17. }