Mercurial > hg > orthanc
annotate OrthancFramework/Resources/Graveyard/Multithreading/BagOfTasks.h @ 5159:f5907aecbaed
conditional usage of malloc_trim
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 02 Feb 2023 11:28:35 +0100 |
parents | 43e613a7756b |
children | 0ea402b4d901 |
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 | |
4870
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
1920 | 7 * |
8 * 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
|
9 * 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
|
10 * 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
|
11 * the License, or (at your option) any later version. |
1920 | 12 * |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * 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
|
16 * Lesser General Public License for more details. |
1920 | 17 * |
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
|
18 * 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
|
19 * 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
|
20 * <http://www.gnu.org/licenses/>. |
1920 | 21 **/ |
22 | |
23 | |
24 #pragma once | |
25 | |
26 #include "../ICommand.h" | |
27 | |
28 #include <list> | |
1975 | 29 #include <cstddef> |
1920 | 30 |
31 namespace Orthanc | |
32 { | |
33 class BagOfTasks : public boost::noncopyable | |
34 { | |
35 private: | |
36 typedef std::list<ICommand*> Tasks; | |
37 | |
38 Tasks tasks_; | |
39 | |
40 public: | |
41 ~BagOfTasks() | |
42 { | |
2016 | 43 for (Tasks::iterator it = tasks_.begin(); it != tasks_.end(); ++it) |
1920 | 44 { |
45 delete *it; | |
46 } | |
47 } | |
48 | |
49 ICommand* Pop() | |
50 { | |
51 ICommand* task = tasks_.front(); | |
52 tasks_.pop_front(); | |
53 return task; | |
54 } | |
55 | |
56 void Push(ICommand* task) // Takes ownership | |
57 { | |
58 if (task != NULL) | |
59 { | |
60 tasks_.push_back(task); | |
61 } | |
62 } | |
63 | |
64 size_t GetSize() const | |
65 { | |
66 return tasks_.size(); | |
67 } | |
68 | |
69 bool IsEmpty() const | |
70 { | |
71 return tasks_.empty(); | |
72 } | |
73 }; | |
74 } |