reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
PyThreadSupport.hxx
Go to the documentation of this file.
1
2#ifndef PYTHREAD_SUPPORT_HXX
3#define PYTHREAD_SUPPORT_HXX
4
5#include <Python.h>
6#include <CXX/Objects.hxx>
7
8namespace resip
9{
10
12{
13 public:
14 PyThreadSupport() : mState(PyGILState_Ensure()) {};
15 ~PyThreadSupport() { PyGILState_Release(mState); };
16
17 private:
18 PyGILState_STATE mState;
19};
20
22{
23 public:
24 PyExternalUser(PyInterpreterState* interpreterState)
25 : mInterpreterState(interpreterState),
26 mThreadState(PyThreadState_New(mInterpreterState)) {};
27
28 class Use
29 {
30 public:
32 : mUser(user)
33 { PyEval_RestoreThread(mUser.getThreadState()); };
34 ~Use() { mUser.setThreadState(PyEval_SaveThread()); };
35 private:
36 PyExternalUser& mUser;
37 };
38
39 friend class Use;
40
41 protected:
42 PyThreadState* getThreadState() { return mThreadState; };
44
45 private:
46 PyInterpreterState* mInterpreterState;
47 PyThreadState* mThreadState;
48};
49
50}
51
52#endif
53
54/* ====================================================================
55 *
56 * Copyright 2013 Daniel Pocock http://danielpocock.com All rights reserved.
57 *
58 * Redistribution and use in source and binary forms, with or without
59 * modification, are permitted provided that the following conditions
60 * are met:
61 *
62 * 1. Redistributions of source code must retain the above copyright
63 * notice, this list of conditions and the following disclaimer.
64 *
65 * 2. Redistributions in binary form must reproduce the above copyright
66 * notice, this list of conditions and the following disclaimer in
67 * the documentation and/or other materials provided with the
68 * distribution.
69 *
70 * 3. Neither the name of the author(s) nor the names of any contributors
71 * may be used to endorse or promote products derived from this software
72 * without specific prior written permission.
73 *
74 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS "AS IS" AND
75 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
76 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
77 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
78 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
79 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
80 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
81 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
82 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
83 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
84 * SUCH DAMAGE.
85 *
86 * ====================================================================
87 *
88 *
89 */
90
Use(PyExternalUser &user)
PyExternalUser(PyInterpreterState *interpreterState)
void setThreadState(PyThreadState *threadState)
PyThreadState * getThreadState()
dcm! – add UnusedChecking(_enum) below;
void list()
Definition userAdmin.cxx:66