Mercurial > hg > orthanc-python
annotate Sources/PythonThreadsAllower.h @ 202:ba4dd45ab937
fix mingw build
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 03 Jul 2024 09:48:42 +0200 |
parents | f34f3a149c22 |
children | 3678a028f1f6 |
rev | line source |
---|---|
184
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Python plugin for Orthanc |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2020-2023 Osimis S.A., Belgium |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 **/ |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 #pragma once |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include "PythonHeaderWrapper.h" |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 #include <boost/noncopyable.hpp> |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 /** |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 * This class implements the RAII pattern for Py_BEGIN_ALLOW_THREADS / |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 * Py_END_ALLOW_THREADS: |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 * https://docs.python.org/3/c-api/init.html#releasing-the-gil-from-extension-code |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 **/ |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 class PythonThreadsAllower : public boost::noncopyable |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 { |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 private: |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 PyThreadState* state_; |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 public: |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 PythonThreadsAllower(); |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 ~PythonThreadsAllower(); |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 static void SetAllowThreads(bool allow); |
f34f3a149c22
added class PythonThreadsAllower
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 }; |