LeechCraft 0.6.70-18450-gabe19ee3b0
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
mutex.h
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#pragma once
10
11#include <QMutex>
12#include "attributes.h"
13
14namespace LC::Util
15{
16 class CAPABILITY("mutex") Mutex
17 {
18 QMutex M_;
19 public:
20 explicit Mutex () = default;
21
22 void lock () ACQUIRE ()
23 {
24 M_.lock ();
25 }
26
27 void unlock () RELEASE ()
28 {
29 M_.unlock ();
30 }
31
32 QMutex& GetMutex ()
33 {
34 return M_;
35 }
36 };
37
39 {
40 Mutex& M_;
41 public:
42 explicit MutexLocker (Mutex& m) ACQUIRE (m)
43 : M_ { m }
44 {
45 M_.lock ();
46 }
47
49 {
50 M_.unlock ();
51 }
52 };
53}
#define RELEASE(...)
Definition attributes.h:21
#define SCOPED_LOCKABLE
Definition attributes.h:19
#define ACQUIRE(...)
Definition attributes.h:20
MutexLocker(Mutex &m) ACQUIRE(m)
Definition mutex.h:42
~MutexLocker() RELEASE()
Definition mutex.h:48
class CAPABILITY("mutex") Mutex
Definition mutex.h:16