diff --git a/src/SdlMutex.cpp b/src/SdlMutex.cpp index 1ad5979..7163e55 100644 --- a/src/SdlMutex.cpp +++ b/src/SdlMutex.cpp @@ -1,5 +1,6 @@ // This is copyrighted software. More information is at the end of this file. #include "SdlMutex.h" +#include SdlMutex::SdlMutex() { @@ -7,6 +8,21 @@ SdlMutex::SdlMutex() throw std::runtime_error(SDL_GetError()); } } + +void SdlMutex::lock() +{ + if (SDL_LockMutex(mutex_) != 0) { + throw std::runtime_error(SDL_GetError()); + } +} + +void SdlMutex::unlock() +{ + if (SDL_UnlockMutex(mutex_) != 0) { + throw std::runtime_error(SDL_GetError()); + } +} + /* Copyright (C) 2021 Nikos Chantziaras. diff --git a/src/SdlMutex.h b/src/SdlMutex.h index 50c8613..0763bc4 100644 --- a/src/SdlMutex.h +++ b/src/SdlMutex.h @@ -3,7 +3,6 @@ #include #include #include -#include /* * RAII wrapper for SDL_mutex. Satisfies std's "Lockable" (SDL 2) or "BasicLockable" (SDL 1) @@ -22,10 +21,7 @@ class SdlMutex final SdlMutex(const SdlMutex&) = delete; auto operator=(const SdlMutex&) -> SdlMutex& = delete; - void lock() noexcept - { - SDL_LockMutex(mutex_); - } + void lock(); #if SDL_VERSION_ATLEAST(2, 0, 0) bool try_lock() noexcept @@ -34,10 +30,7 @@ class SdlMutex final } #endif - void unlock() noexcept - { - SDL_UnlockMutex(mutex_); - } + void unlock(); private: SDL_mutex* mutex_ = SDL_CreateMutex();