annotate OrthancFramework/Sources/MultiThreading/Mutex.h @ 5437:85da6dcd0e08

merge
author Alain Mazy <am@osimis.io>
date Wed, 22 Nov 2023 09:39:35 +0100
parents 08b5516c6e5e
children 48b8dae6dc77
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5398
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public License
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * as published by the Free Software Foundation, either version 3 of
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * the License, or (at your option) any later version.
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * Lesser General Public License for more details.
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * License along with this program. If not, see
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * <http://www.gnu.org/licenses/>.
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #pragma once
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #if !defined(__EMSCRIPTEN__)
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 # include <boost/thread/mutex.hpp>
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #endif
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 namespace Orthanc
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 {
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 // Wrapper class for compatibility with Emscripten
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #if defined(__EMSCRIPTEN__)
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 class ORTHANC_PUBLIC Mutex : public boost::noncopyable
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 {
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 public:
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 class ORTHANC_PUBLIC ScopedLock : public boost::noncopyable
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 {
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 public:
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 explicit ScopedLock(Mutex& mutex)
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 {
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 }
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 };
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 };
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 #else
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 class ORTHANC_PUBLIC Mutex : public boost::noncopyable
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 {
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 private:
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 boost::mutex mutex_;
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 public:
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 class ORTHANC_PUBLIC ScopedLock : public boost::noncopyable
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 {
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 private:
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 boost::mutex::scoped_lock lock_;
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 public:
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 explicit ScopedLock(Mutex& mutex) :
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 lock_(mutex.mutex_)
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 {
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 }
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 };
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 };
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 #endif
08b5516c6e5e compatibility of OrthancFramework with latest releases of Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 }