Mercurial > hg > orthanc-java
comparison Plugin/Mutex.h @ 0:3ecef5782f2c
initial commit
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 18 Oct 2023 17:59:44 +0200 |
parents | |
children | 1c407ba1d311 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3ecef5782f2c |
---|---|
1 /** | |
2 * SPDX-FileCopyrightText: 2023 Sebastien Jodogne, UCLouvain, Belgium | |
3 * SPDX-License-Identifier: GPL-3.0-or-later | |
4 */ | |
5 | |
6 /** | |
7 * Java plugin for Orthanc | |
8 * Copyright (C) 2023 Sebastien Jodogne, UCLouvain, Belgium | |
9 * | |
10 * This program is free software: you can redistribute it and/or | |
11 * modify it under the terms of the GNU General Public License as | |
12 * published by the Free Software Foundation, either version 3 of the | |
13 * License, or (at your option) any later version. | |
14 * | |
15 * This program is distributed in the hope that it will be useful, but | |
16 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 * General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
22 **/ | |
23 | |
24 | |
25 #pragma once | |
26 | |
27 #include "NonCopyable.h" | |
28 | |
29 class Mutex : public NonCopyable | |
30 { | |
31 private: | |
32 struct PImpl; | |
33 PImpl *pimpl_; | |
34 | |
35 void Lock(); | |
36 | |
37 void Unlock(); | |
38 | |
39 public: | |
40 Mutex(); | |
41 | |
42 ~Mutex(); | |
43 | |
44 class Locker : public NonCopyable | |
45 { | |
46 private: | |
47 Mutex& mutex_; | |
48 | |
49 public: | |
50 Locker(Mutex& mutex) : | |
51 mutex_(mutex) | |
52 { | |
53 mutex_.Lock(); | |
54 } | |
55 | |
56 ~Locker() | |
57 { | |
58 mutex_.Unlock(); | |
59 } | |
60 }; | |
61 }; |