Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(47509)

Side by Side Diff: Include/pystate.h

Issue 10915: Make the PyGILState API compatible with multiple interpreters
Patch Set: Created 8 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Modules/_ctypes/callbacks.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* Thread and interpreter state structures and their interfaces */ 2 /* Thread and interpreter state structures and their interfaces */
3 3
4 4
5 #ifndef Py_PYSTATE_H 5 #ifndef Py_PYSTATE_H
6 #define Py_PYSTATE_H 6 #define Py_PYSTATE_H
7 #ifdef __cplusplus 7 #ifdef __cplusplus
8 extern "C" { 8 extern "C" {
9 #endif 9 #endif
10 10
(...skipping 20 matching lines...) Expand all
31 PyObject *codec_search_cache; 31 PyObject *codec_search_cache;
32 PyObject *codec_error_registry; 32 PyObject *codec_error_registry;
33 int codecs_initialized; 33 int codecs_initialized;
34 34
35 #ifdef HAVE_DLOPEN 35 #ifdef HAVE_DLOPEN
36 int dlopenflags; 36 int dlopenflags;
37 #endif 37 #endif
38 #ifdef WITH_TSC 38 #ifdef WITH_TSC
39 int tscdump; 39 int tscdump;
40 #endif 40 #endif
41 41 /* For PyGILState_* APIs */
42 #ifdef WITH_THREAD
43 int auto_tls_key;
44 #endif
42 } PyInterpreterState; 45 } PyInterpreterState;
43 #endif 46 #endif
44 47
45 48
46 /* State unique per thread */ 49 /* State unique per thread */
47 50
48 struct _frame; /* Avoid including frameobject.h */ 51 struct _frame; /* Avoid including frameobject.h */
49 52
50 #ifndef Py_LIMITED_API 53 #ifndef Py_LIMITED_API
51 /* Py_tracefunc return -1 when raising an exception, or 0 for success. */ 54 /* Py_tracefunc return -1 when raising an exception, or 0 for success. */
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 122
120 123
121 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_New(void); 124 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_New(void);
122 PyAPI_FUNC(void) PyInterpreterState_Clear(PyInterpreterState *); 125 PyAPI_FUNC(void) PyInterpreterState_Clear(PyInterpreterState *);
123 PyAPI_FUNC(void) PyInterpreterState_Delete(PyInterpreterState *); 126 PyAPI_FUNC(void) PyInterpreterState_Delete(PyInterpreterState *);
124 PyAPI_FUNC(int) _PyState_AddModule(PyObject*, struct PyModuleDef*); 127 PyAPI_FUNC(int) _PyState_AddModule(PyObject*, struct PyModuleDef*);
125 PyAPI_FUNC(PyObject*) PyState_FindModule(struct PyModuleDef*); 128 PyAPI_FUNC(PyObject*) PyState_FindModule(struct PyModuleDef*);
126 129
127 PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *); 130 PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *);
128 PyAPI_FUNC(PyThreadState *) _PyThreadState_Prealloc(PyInterpreterState *); 131 PyAPI_FUNC(PyThreadState *) _PyThreadState_Prealloc(PyInterpreterState *);
129 PyAPI_FUNC(void) _PyThreadState_Init(PyThreadState *); 132 PyAPI_FUNC(void) _PyThreadState_Init(PyInterpreterState *, PyThreadState *);
130 PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *); 133 PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *);
131 PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *); 134 PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *);
132 #ifdef WITH_THREAD 135 #ifdef WITH_THREAD
133 PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void); 136 PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);
134 #endif 137 #endif
135 138
136 PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void); 139 PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void);
137 PyAPI_FUNC(PyThreadState *) PyThreadState_Swap(PyThreadState *); 140 PyAPI_FUNC(PyThreadState *) PyThreadState_Swap(PyThreadState *);
138 PyAPI_FUNC(PyObject *) PyThreadState_GetDict(void); 141 PyAPI_FUNC(PyObject *) PyThreadState_GetDict(void);
139 PyAPI_FUNC(int) PyThreadState_SetAsyncExc(long, PyObject *); 142 PyAPI_FUNC(int) PyThreadState_SetAsyncExc(long, PyObject *);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 PyGILState_Release() to ensure Python is left in the same state. Even 176 PyGILState_Release() to ensure Python is left in the same state. Even
174 though recursive calls are allowed, these handles can *not* be shared - 177 though recursive calls are allowed, these handles can *not* be shared -
175 each unique call to PyGILState_Ensure must save the handle for its 178 each unique call to PyGILState_Ensure must save the handle for its
176 call to PyGILState_Release. 179 call to PyGILState_Release.
177 180
178 When the function returns, the current thread will hold the GIL. 181 When the function returns, the current thread will hold the GIL.
179 182
180 Failure is a fatal error. 183 Failure is a fatal error.
181 */ 184 */
182 PyAPI_FUNC(PyGILState_STATE) PyGILState_Ensure(void); 185 PyAPI_FUNC(PyGILState_STATE) PyGILState_Ensure(void);
186 PyAPI_FUNC(PyGILState_STATE) PyGILState_EnsureEx(PyInterpreterState *);
183 187
184 /* Release any resources previously acquired. After this call, Python's 188 /* Release any resources previously acquired. After this call, Python's
185 state will be the same as it was prior to the corresponding 189 state will be the same as it was prior to the corresponding
186 PyGILState_Ensure() call (but generally this state will be unknown to 190 PyGILState_Ensure() call (but generally this state will be unknown to
187 the caller, hence the use of the GILState API.) 191 the caller, hence the use of the GILState API.)
188 192
189 Every call to PyGILState_Ensure must be matched by a call to 193 Every call to PyGILState_Ensure must be matched by a call to
190 PyGILState_Release on the same thread. 194 PyGILState_Release on the same thread.
191 */ 195 */
192 PyAPI_FUNC(void) PyGILState_Release(PyGILState_STATE); 196 PyAPI_FUNC(void) PyGILState_Release(PyGILState_STATE);
197 PyAPI_FUNC(void) PyGILState_ReleaseEx(PyInterpreterState *, PyGILState_STATE);
193 198
194 /* Helper/diagnostic function - get the current thread state for 199 /* Helper/diagnostic function - get the current thread state for
195 this thread. May return NULL if no GILState API has been used 200 this thread. May return NULL if no GILState API has been used
196 on the current thread. Note the main thread always has such a 201 on the current thread. Note the main thread always has such a
197 thread-state, even if no auto-thread-state call has been made 202 thread-state, even if no auto-thread-state call has been made
198 on the main thread. 203 on the main thread.
199 */ 204 */
200 PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void); 205 PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void);
206 PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadStateEx(PyInterpreterState * );
201 207
202 /* The implementation of sys._current_frames() Returns a dict mapping 208 /* The implementation of sys._current_frames() Returns a dict mapping
203 thread id to that thread's current frame. 209 thread id to that thread's current frame.
204 */ 210 */
205 #ifndef Py_LIMITED_API 211 #ifndef Py_LIMITED_API
206 PyAPI_FUNC(PyObject *) _PyThread_CurrentFrames(void); 212 PyAPI_FUNC(PyObject *) _PyThread_CurrentFrames(void);
207 #endif 213 #endif
208 214
209 /* Routines for advanced debuggers, requested by David Beazley. 215 /* Routines for advanced debuggers, requested by David Beazley.
210 Don't use unless you know what you are doing! */ 216 Don't use unless you know what you are doing! */
211 #ifndef Py_LIMITED_API 217 #ifndef Py_LIMITED_API
212 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void); 218 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void);
213 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *); 219 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *);
214 PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *); 220 PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
215 PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *); 221 PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *);
216 222
217 typedef struct _frame *(*PyThreadFrameGetter)(PyThreadState *self_); 223 typedef struct _frame *(*PyThreadFrameGetter)(PyThreadState *self_);
218 #endif 224 #endif
219 225
220 /* hook for PyEval_GetFrame(), requested for Psyco */ 226 /* hook for PyEval_GetFrame(), requested for Psyco */
221 #ifndef Py_LIMITED_API 227 #ifndef Py_LIMITED_API
222 PyAPI_DATA(PyThreadFrameGetter) _PyThreadState_GetFrame; 228 PyAPI_DATA(PyThreadFrameGetter) _PyThreadState_GetFrame;
223 #endif 229 #endif
224 230
225 #ifdef __cplusplus 231 #ifdef __cplusplus
226 } 232 }
227 #endif 233 #endif
228 #endif /* !Py_PYSTATE_H */ 234 #endif /* !Py_PYSTATE_H */
OLDNEW
« no previous file with comments | « no previous file | Modules/_ctypes/callbacks.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+