Honeycomb  0.1
Component-Model Framework
Mutex.h
Go to the documentation of this file.
1 // Honeycomb, Copyright (C) 2015 NewGamePlus Inc. Distributed under the Boost Software License v1.0.
2 #pragma once
3 
4 #include "Honey/Core/Core.h"
5 #include "Honey/Thread/Lock/platform/Mutex.h"
6 
7 namespace honey
8 {
9 
10 template<class Lockable> class UniqueLock;
11 
13 
17 class Mutex : platform::Mutex
18 {
19  typedef platform::Mutex Super;
20 public:
21  typedef Super::Handle Handle;
23 
24  Mutex() = default;
26  Mutex(const Mutex&) {}
27 
29  Mutex& operator=(const Mutex&) { return *this; }
30 
32  void lock() { Super::lock(); }
34  void unlock() { Super::unlock(); }
36  bool tryLock() { return Super::tryLock(); }
37 
39  Handle& handle() { return Super::handle(); }
40 };
41 
42 }
A scoped lock that references any lockable. Locks on construction and unlocks on destruction.
Definition: Mutex.h:10
Super::Handle Handle
Definition: Mutex.h:21
void lock(Locks &&...locks)
Lock all lockables safely without deadlocking.
Definition: Util.h:110
Mutex & operator=(const Mutex &)
Can't copy, silently does nothing.
Definition: Mutex.h:29
void lock()
Acquire the lock. Thread suspends until lock becomes available.
Definition: Mutex.h:32
UniqueLock< Mutex > Scoped
Definition: Mutex.h:22
Mutex()=default
bool tryLock()
Attempt to acquire the lock, returns immediately. Returns true if the lock was acquired, false otherwise.
Definition: Mutex.h:36
Mutex(const Mutex &)
Can't copy, silently inits to default.
Definition: Mutex.h:26
void unlock()
Release the lock.
Definition: Mutex.h:34
Handle & handle()
Get platform handle.
Definition: Mutex.h:39
A thread lock where the lock is acquired by suspending thread execution until it becomes available...
Definition: Mutex.h:17
Global Honeycomb namespace.
int tryLock(Lock &l, Locks &...ls)
Try to lock all lockables. Locks either all or none.
Definition: Util.h:26