2 #ifndef UVCC_THREAD__HPP 3 #define UVCC_THREAD__HPP 17 using uv_t = ::uv_mutex_t;
23 ~mutex()
noexcept { ::uv_mutex_destroy(&uv_mutex); }
24 mutex() {
if (::uv_mutex_init(&uv_mutex) < 0)
throw std::runtime_error(
__PRETTY_FUNCTION__); }
26 mutex(
const mutex&) =
delete;
27 mutex& operator =(
const mutex&) =
delete;
29 mutex(mutex&&) =
delete;
30 mutex& operator =(mutex&&) =
delete;
33 void lock()
noexcept { ::uv_mutex_lock(&uv_mutex); }
34 bool try_lock()
noexcept {
return ::uv_mutex_trylock(&uv_mutex) == 0; }
35 void unlock()
noexcept { ::uv_mutex_unlock(&uv_mutex); }
38 explicit operator
const uv_t*()
const noexcept {
return &uv_mutex; }
39 explicit operator uv_t*()
noexcept {
return &uv_mutex; }
Namespace for all uvcc definitions.