Mercurial > hg > orthanc
annotate OrthancFramework/Resources/Graveyard/Multithreading/BagOfTasks.h @ 4349:85237ae3a076
relax CheckOrthancFrameworkSymbols.py about one friend stream function
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sun, 06 Dec 2020 12:47:54 +0100 |
parents | bf7b9edf6b81 |
children | d9473bd5ed43 |
rev | line source |
---|---|
1920 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
3640
94f4a18a79cc
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
1920 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
10 * the License, or (at your option) any later version. |
1920 | 11 * |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
15 * Lesser General Public License for more details. |
1920 | 16 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
18 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
1920 | 20 **/ |
21 | |
22 | |
23 #pragma once | |
24 | |
25 #include "../ICommand.h" | |
26 | |
27 #include <list> | |
1975 | 28 #include <cstddef> |
1920 | 29 |
30 namespace Orthanc | |
31 { | |
32 class BagOfTasks : public boost::noncopyable | |
33 { | |
34 private: | |
35 typedef std::list<ICommand*> Tasks; | |
36 | |
37 Tasks tasks_; | |
38 | |
39 public: | |
40 ~BagOfTasks() | |
41 { | |
2016 | 42 for (Tasks::iterator it = tasks_.begin(); it != tasks_.end(); ++it) |
1920 | 43 { |
44 delete *it; | |
45 } | |
46 } | |
47 | |
48 ICommand* Pop() | |
49 { | |
50 ICommand* task = tasks_.front(); | |
51 tasks_.pop_front(); | |
52 return task; | |
53 } | |
54 | |
55 void Push(ICommand* task) // Takes ownership | |
56 { | |
57 if (task != NULL) | |
58 { | |
59 tasks_.push_back(task); | |
60 } | |
61 } | |
62 | |
63 size_t GetSize() const | |
64 { | |
65 return tasks_.size(); | |
66 } | |
67 | |
68 bool IsEmpty() const | |
69 { | |
70 return tasks_.empty(); | |
71 } | |
72 }; | |
73 } |