Mercurial > hg > orthanc
comparison Core/MultiThreading/Semaphore.h @ 2884:497a637366b4 db-changes
integration mainline->db-changes
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 12 Oct 2018 15:18:10 +0200 |
parents | 6e7e5ed91c2d f790999a250a |
children | 4e43e67f8ecf |
comparison
equal
deleted
inserted
replaced
1762:2b91363cc1d1 | 2884:497a637366b4 |
---|---|
1 /** | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
4 * Department, University Hospital of Liege, Belgium | 4 * Department, University Hospital of Liege, Belgium |
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium | |
5 * | 6 * |
6 * This program is free software: you can redistribute it and/or | 7 * This program is free software: you can redistribute it and/or |
7 * modify it under the terms of the GNU General Public License as | 8 * modify it under the terms of the GNU General Public License as |
8 * published by the Free Software Foundation, either version 3 of the | 9 * published by the Free Software Foundation, either version 3 of the |
9 * License, or (at your option) any later version. | 10 * License, or (at your option) any later version. |
41 { | 42 { |
42 private: | 43 private: |
43 unsigned int count_; | 44 unsigned int count_; |
44 boost::mutex mutex_; | 45 boost::mutex mutex_; |
45 boost::condition_variable condition_; | 46 boost::condition_variable condition_; |
47 | |
48 void Release(); | |
49 | |
50 void Acquire(); | |
46 | 51 |
47 public: | 52 public: |
48 explicit Semaphore(unsigned int count); | 53 explicit Semaphore(unsigned int count); |
49 | 54 |
50 void Release(); | 55 class Locker : public boost::noncopyable |
56 { | |
57 private: | |
58 Semaphore& that_; | |
51 | 59 |
52 void Acquire(); | 60 public: |
61 explicit Locker(Semaphore& that) : | |
62 that_(that) | |
63 { | |
64 that_.Acquire(); | |
65 } | |
66 | |
67 ~Locker() | |
68 { | |
69 that_.Release(); | |
70 } | |
71 }; | |
53 }; | 72 }; |
54 } | 73 } |