diff options
author | Matthew Gregan <[email protected]> | 2016-11-04 16:35:46 +1300 |
---|---|---|
committer | Paul Adenot <[email protected]> | 2016-11-15 14:33:04 +0100 |
commit | 7fec421f8b913c58c4baa4db595868009d305ad0 (patch) | |
tree | 8d005ca603fecb0843a871fa4bcc540dae756fce | |
parent | 847e1b8fea27125942eaa403eee4b146176970a1 (diff) | |
download | cubeb-7fec421f8b913c58c4baa4db595868009d305ad0.tar.gz cubeb-7fec421f8b913c58c4baa4db595868009d305ad0.zip |
use std::lock_guard.
-rw-r--r-- | src/cubeb_utils.h | 15 | ||||
-rw-r--r-- | src/cubeb_utils_unix.h | 4 | ||||
-rw-r--r-- | src/cubeb_utils_win.h | 4 |
3 files changed, 6 insertions, 17 deletions
diff --git a/src/cubeb_utils.h b/src/cubeb_utils.h index b6b6eac..94e5ab0 100644 --- a/src/cubeb_utils.h +++ b/src/cubeb_utils.h @@ -11,6 +11,7 @@ #include <stdint.h> #include <string.h> #include <assert.h> +#include <mutex> #include <type_traits> #if defined(WIN32) #include "cubeb_utils_win.h" @@ -201,18 +202,6 @@ private: size_t length_; }; -struct auto_lock { - explicit auto_lock(owned_critical_section & lock) - : lock(lock) - { - lock.enter(); - } - ~auto_lock() - { - lock.leave(); - } -private: - owned_critical_section & lock; -}; +using auto_lock = std::lock_guard<owned_critical_section>; #endif /* CUBEB_UTILS */ diff --git a/src/cubeb_utils_unix.h b/src/cubeb_utils_unix.h index 80219d5..4876d01 100644 --- a/src/cubeb_utils_unix.h +++ b/src/cubeb_utils_unix.h @@ -48,7 +48,7 @@ public: #endif } - void enter() + void lock() { #ifndef NDEBUG int r = @@ -59,7 +59,7 @@ public: #endif } - void leave() + void unlock() { #ifndef NDEBUG int r = diff --git a/src/cubeb_utils_win.h b/src/cubeb_utils_win.h index 2b094cd..0112ad6 100644 --- a/src/cubeb_utils_win.h +++ b/src/cubeb_utils_win.h @@ -29,7 +29,7 @@ public: DeleteCriticalSection(&critical_section); } - void enter() + void lock() { EnterCriticalSection(&critical_section); #ifndef NDEBUG @@ -38,7 +38,7 @@ public: #endif } - void leave() + void unlock() { #ifndef NDEBUG /* GetCurrentThreadId cannot return 0: it is not a the valid thread id */ |