summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Dahlin <johan@src.gnome.org>2005-07-17 20:05:47 +0000
committerJohan Dahlin <johan@src.gnome.org>2005-07-17 20:05:47 +0000
commit4d83c8260c2a95b29d5375bfa6c46bd8dc1309d4 (patch)
tree16fe16ab580184e597eb1681a1269596a0168f32
parent233789c73ffcbbe18b8dffdcf91416875f99c3a4 (diff)
downloadpygobject-4d83c8260c2a95b29d5375bfa6c46bd8dc1309d4.tar.gz
Remove pre python 2.3.5 compatibility. Simplifies thread handling.
* gobject/pygobject.h: * gobject/gobjectmodule.c (pyg_gil_state_ensure_py23) (pyg_gil_state_release_py23): Remove pre python 2.3.5 compatibility. Simplifies thread handling.
-rw-r--r--gobject/gobjectmodule.c48
-rw-r--r--gobject/pygobject.h15
2 files changed, 10 insertions, 53 deletions
diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c
index e038bfa0..603ca231 100644
--- a/gobject/gobjectmodule.c
+++ b/gobject/gobjectmodule.c
@@ -1926,12 +1926,6 @@ pyg_enable_threads ()
pygobject_api_functions.threads_enabled = TRUE;
pyg_thread_state_tls_key = PyThread_create_key();
}
- if (PYGIL_API_IS_BUGGY && !use_gil_state_api) {
- PyThreadState* state;
- state = PyThreadState_Get();
- if ( state != NULL )
- PyThread_set_key_value(pyg_thread_state_tls_key, state);
- }
return 0;
#else
@@ -1941,54 +1935,16 @@ pyg_enable_threads ()
#endif
}
-static PyThreadState *
-pyg_find_thread_state (void)
-{
- PyThreadState* state;
-
- if (pyg_thread_state_tls_key == -1)
- return NULL;
- state = PyThread_get_key_value(pyg_thread_state_tls_key);
- if (state == NULL) {
- state = PyGILState_GetThisThreadState();
- if (state != NULL)
- PyThread_set_key_value(pyg_thread_state_tls_key, state);
- }
- return state;
-}
-
static int
pyg_gil_state_ensure_py23 (void)
{
- if (PYGIL_API_IS_BUGGY && !use_gil_state_api) {
- PyThreadState* state = pyg_find_thread_state();
-
- if (state == NULL)
- return PyGILState_LOCKED;
-
- if (state == _PyThreadState_Current)
- return PyGILState_LOCKED;
- else {
- PyEval_RestoreThread(state);
- return PyGILState_UNLOCKED;
- }
- } else {
- return PyGILState_Ensure();
- }
+ return PyGILState_Ensure();
}
static void
pyg_gil_state_release_py23 (int flag)
{
- if (PYGIL_API_IS_BUGGY && !use_gil_state_api) {
- if (flag == PyGILState_UNLOCKED) {
- PyThreadState* state = pyg_find_thread_state();
- if (state != NULL)
- PyEval_ReleaseThread(state);
- }
- } else {
- PyGILState_Release(flag);
- }
+ PyGILState_Release(flag);
}
static PyObject *
diff --git a/gobject/pygobject.h b/gobject/pygobject.h
index 3bba3acd..55c72b12 100644
--- a/gobject/pygobject.h
+++ b/gobject/pygobject.h
@@ -9,12 +9,8 @@
G_BEGIN_DECLS
-/* Work around bugs in PyGILState api fixed in 2.4.0a4 */
-#if PY_VERSION_HEX < 0x020400A4
-#define PYGIL_API_IS_BUGGY TRUE
-#else
+/* This is deprecated, don't use */
#define PYGIL_API_IS_BUGGY FALSE
-#endif
/* PyGClosure is a _private_ structure */
typedef void (* PyClosureExceptionHandler) (GValue *ret, guint n_param_values, const GValue *params);
@@ -161,8 +157,11 @@ struct _PyGObject_Functions {
gboolean threads_enabled;
int (*enable_threads) (void);
+
+ /* These 2 are deprecated */
int (*gil_state_ensure) (void);
void (*gil_state_release) (int flag);
+
void (*register_class_init) (GType gtype, PyGClassInitFunc class_init);
void (*register_interface_info) (GType gtype, const GInterfaceInfo *info);
void (*closure_set_exception_handler) (GClosure *closure, PyClosureExceptionHandler handler);
@@ -245,10 +244,12 @@ struct _PyGObject_Functions *_PyGObject_API;
#define pyg_threads_enabled (_PyGObject_API->threads_enabled)
-#define pyg_gil_state_ensure() (_PyGObject_API->threads_enabled? (_PyGObject_API->gil_state_ensure()) : 0)
+#define pyg_gil_state_ensure() \
+ (_PyGObject_API->threads_enabled ? \
+ (PyGILState_Ensure()) : 0)
#define pyg_gil_state_release(state) G_STMT_START { \
if (_PyGObject_API->threads_enabled) \
- _PyGObject_API->gil_state_release(state); \
+ PyGILState_Release(state); \
} G_STMT_END
#define pyg_begin_allow_threads \