summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-12-15 22:59:16 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-12-15 22:59:16 (GMT)
commit810023db3e91c18f428e27378d00c3a5a56330c6 (patch)
tree98b7710d8855ccbed5d84e6d64ff617fe7e53570 /Include
parent119cda0fd25561c2a21212c80f211af966104297 (diff)
downloadcpython-810023db3e91c18f428e27378d00c3a5a56330c6.zip
cpython-810023db3e91c18f428e27378d00c3a5a56330c6.tar.gz
cpython-810023db3e91c18f428e27378d00c3a5a56330c6.tar.bz2
Issue #8844: Regular and recursive lock acquisitions can now be interrupted
by signals on platforms using pthreads. Patch by Reid Kleckner.
Diffstat (limited to 'Include')
-rw-r--r--Include/pythread.h23
1 files changed, 19 insertions, 4 deletions
diff --git a/Include/pythread.h b/Include/pythread.h
index ff8fdd2..9806c61 100644
--- a/Include/pythread.h
+++ b/Include/pythread.h
@@ -9,6 +9,14 @@ typedef void *PyThread_type_sema;
extern "C" {
#endif
+/* Return status codes for Python lock acquisition. Chosen for maximum
+ * backwards compatibility, ie failure -> 0, success -> 1. */
+typedef enum PyLockStatus {
+ PY_LOCK_FAILURE = 0,
+ PY_LOCK_ACQUIRED = 1,
+ PY_LOCK_INTR
+} PyLockStatus;
+
PyAPI_FUNC(void) PyThread_init_thread(void);
PyAPI_FUNC(long) PyThread_start_new_thread(void (*)(void *), void *);
PyAPI_FUNC(void) PyThread_exit_thread(void);
@@ -49,11 +57,18 @@ PyAPI_FUNC(int) PyThread_acquire_lock(PyThread_type_lock, int);
even when the lock can't be acquired.
If microseconds > 0, the call waits up to the specified duration.
If microseconds < 0, the call waits until success (or abnormal failure)
-
+
microseconds must be less than PY_TIMEOUT_MAX. Behaviour otherwise is
- undefined. */
-PyAPI_FUNC(int) PyThread_acquire_lock_timed(PyThread_type_lock,
- PY_TIMEOUT_T microseconds);
+ undefined.
+
+ If intr_flag is true and the acquire is interrupted by a signal, then the
+ call will return PY_LOCK_INTR. The caller may reattempt to acquire the
+ lock.
+*/
+PyAPI_FUNC(PyLockStatus) PyThread_acquire_lock_timed(PyThread_type_lock,
+ PY_TIMEOUT_T microseconds,
+ int intr_flag);
+
PyAPI_FUNC(void) PyThread_release_lock(PyThread_type_lock);
PyAPI_FUNC(size_t) PyThread_get_stacksize(void);