[Python-checkins] python/dist/src/Include pystate.h,2.23,2.24 pythread.h,2.20,2.21
mhammond@users.sourceforge.net
mhammond@users.sourceforge.net
Sat, 19 Apr 2003 08:42:19 -0700
- Previous message: [Python-checkins] python/dist/src/Python ceval.c,2.358,2.359 pystate.c,2.25,2.26 pythonrun.c,2.190,2.191 thread.c,2.45,2.46 thread_sgi.h,2.16,2.17
- Next message: [Python-checkins] python/dist/src/Lib/test test_capi.py,1.4,1.5
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Include
In directory sc8-pr-cvs1:/tmp/cvs-serv30725/Include
Modified Files:
pystate.h pythread.h
Log Message:
New PyGILState_ API - implements pep 311, from patch 684256.
Index: pystate.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/pystate.h,v
retrieving revision 2.23
retrieving revision 2.24
diff -C2 -d -r2.23 -r2.24
*** pystate.h 19 Mar 2003 00:35:35 -0000 2.23
--- pystate.h 19 Apr 2003 15:41:45 -0000 2.24
***************
*** 73,76 ****
--- 73,77 ----
int tick_counter;
+ int gilstate_counter;
/* XXX signal handlers should also be here */
***************
*** 104,107 ****
--- 105,153 ----
#define PyThreadState_GET() (_PyThreadState_Current)
#endif
+
+ typedef
+ enum {PyGILState_LOCKED, PyGILState_UNLOCKED}
+ PyGILState_STATE;
+
+ /* Ensure that the current thread is ready to call the Python
+ C API, regardless of the current state of Python, or of its
+ thread lock. This may be called as many times as desired
+ by a thread so long as each call is matched with a call to
+ PyGILState_Release(). In general, other thread-state APIs may
+ be used between _Ensure() and _Release() calls, so long as the
+ thread-state is restored to its previous state before the Release().
+ For example, normal use of the Py_BEGIN_ALLOW_THREADS/
+ Py_END_ALLOW_THREADS macros are acceptable.
+
+ The return value is an opaque "handle" to the thread state when
+ PyGILState_Acquire() was called, and must be passed to
+ PyGILState_Release() to ensure Python is left in the same state. Even
+ though recursive calls are allowed, these handles can *not* be shared -
+ each unique call to PyGILState_Ensure must save the handle for its
+ call to PyGILState_Release.
+
+ When the function returns, the current thread will hold the GIL.
+
+ Failure is a fatal error.
+ */
+ PyAPI_FUNC(PyGILState_STATE) PyGILState_Ensure(void);
+
+ /* Release any resources previously acquired. After this call, Python's
+ state will be the same as it was prior to the corresponding
+ PyGILState_Acquire call (but generally this state will be unknown to
+ the caller, hence the use of the GILState API.)
+
+ Every call to PyGILState_Ensure must be matched by a call to
+ PyGILState_Release on the same thread.
+ */
+ PyAPI_FUNC(void) PyGILState_Release(PyGILState_STATE);
+
+ /* Helper/diagnostic function - get the current thread state for
+ this thread. May return NULL if no GILState API has been used
+ on the current thread. Note the main thread always has such a
+ thread-state, even if no auto-thread-state call has been made
+ on the main thread.
+ */
+ PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void);
/* Routines for advanced debuggers, requested by David Beazley.
Index: pythread.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/pythread.h,v
retrieving revision 2.20
retrieving revision 2.21
diff -C2 -d -r2.20 -r2.21
*** pythread.h 12 Aug 2002 07:21:57 -0000 2.20
--- pythread.h 19 Apr 2003 15:41:45 -0000 2.21
***************
*** 31,38 ****
--- 31,40 ----
#endif
+ /* Thread Local Storage (TLS) API */
PyAPI_FUNC(int) PyThread_create_key(void);
PyAPI_FUNC(void) PyThread_delete_key(int);
PyAPI_FUNC(int) PyThread_set_key_value(int, void *);
PyAPI_FUNC(void *) PyThread_get_key_value(int);
+ PyAPI_FUNC(void) PyThread_delete_key_value(int key);
#ifdef __cplusplus
- Previous message: [Python-checkins] python/dist/src/Python ceval.c,2.358,2.359 pystate.c,2.25,2.26 pythonrun.c,2.190,2.191 thread.c,2.45,2.46 thread_sgi.h,2.16,2.17
- Next message: [Python-checkins] python/dist/src/Lib/test test_capi.py,1.4,1.5
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]