Mercurial > cpython-lru_cache-weakref
annotate Include/pythread.h @ 78069:a8aa77458e12 3.2
Add c_size_t and c_ssize_t to the ctypes summary table.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Thu, 12 Jul 2012 20:31:50 +0200 |
| parents | b750c45a772c |
| children | 383a7301616b |
| rev | line source |
|---|---|
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 |
|
13445
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
2 #ifndef Py_PYTHREAD_H |
|
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
3 #define Py_PYTHREAD_H |
|
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
4 |
|
9679
877d23bd5bdc
Thanks to Chris Herborth, the thread primitives now have proper Py*
Guido van Rossum <guido@python.org>
parents:
9586
diff
changeset
|
5 typedef void *PyThread_type_lock; |
|
877d23bd5bdc
Thanks to Chris Herborth, the thread primitives now have proper Py*
Guido van Rossum <guido@python.org>
parents:
9586
diff
changeset
|
6 typedef void *PyThread_type_sema; |
|
1047
6b5a34db21fe
Added C++ support in thread.h; don't use signals if not strictly
Sjoerd Mullender <sjoerd@acm.org>
parents:
961
diff
changeset
|
7 |
|
6b5a34db21fe
Added C++ support in thread.h; don't use signals if not strictly
Sjoerd Mullender <sjoerd@acm.org>
parents:
961
diff
changeset
|
8 #ifdef __cplusplus |
|
6b5a34db21fe
Added C++ support in thread.h; don't use signals if not strictly
Sjoerd Mullender <sjoerd@acm.org>
parents:
961
diff
changeset
|
9 extern "C" { |
|
6b5a34db21fe
Added C++ support in thread.h; don't use signals if not strictly
Sjoerd Mullender <sjoerd@acm.org>
parents:
961
diff
changeset
|
10 #endif |
|
6b5a34db21fe
Added C++ support in thread.h; don't use signals if not strictly
Sjoerd Mullender <sjoerd@acm.org>
parents:
961
diff
changeset
|
11 |
|
66946
b750c45a772c
Issue #8844: Regular and recursive lock acquisitions can now be interrupted
Antoine Pitrou <solipsis@pitrou.net>
parents:
64660
diff
changeset
|
12 /* Return status codes for Python lock acquisition. Chosen for maximum |
|
b750c45a772c
Issue #8844: Regular and recursive lock acquisitions can now be interrupted
Antoine Pitrou <solipsis@pitrou.net>
parents:
64660
diff
changeset
|
13 * backwards compatibility, ie failure -> 0, success -> 1. */ |
|
b750c45a772c
Issue #8844: Regular and recursive lock acquisitions can now be interrupted
Antoine Pitrou <solipsis@pitrou.net>
parents:
64660
diff
changeset
|
14 typedef enum PyLockStatus { |
|
b750c45a772c
Issue #8844: Regular and recursive lock acquisitions can now be interrupted
Antoine Pitrou <solipsis@pitrou.net>
parents:
64660
diff
changeset
|
15 PY_LOCK_FAILURE = 0, |
|
b750c45a772c
Issue #8844: Regular and recursive lock acquisitions can now be interrupted
Antoine Pitrou <solipsis@pitrou.net>
parents:
64660
diff
changeset
|
16 PY_LOCK_ACQUIRED = 1, |
|
b750c45a772c
Issue #8844: Regular and recursive lock acquisitions can now be interrupted
Antoine Pitrou <solipsis@pitrou.net>
parents:
64660
diff
changeset
|
17 PY_LOCK_INTR |
|
b750c45a772c
Issue #8844: Regular and recursive lock acquisitions can now be interrupted
Antoine Pitrou <solipsis@pitrou.net>
parents:
64660
diff
changeset
|
18 } PyLockStatus; |
|
b750c45a772c
Issue #8844: Regular and recursive lock acquisitions can now be interrupted
Antoine Pitrou <solipsis@pitrou.net>
parents:
64660
diff
changeset
|
19 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
21766
diff
changeset
|
20 PyAPI_FUNC(void) PyThread_init_thread(void); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
21766
diff
changeset
|
21 PyAPI_FUNC(long) PyThread_start_new_thread(void (*)(void *), void *); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
21766
diff
changeset
|
22 PyAPI_FUNC(void) PyThread_exit_thread(void); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
21766
diff
changeset
|
23 PyAPI_FUNC(long) PyThread_get_thread_ident(void); |
|
5194
52f3dc41f6c4
Add Macros defining new names for all external symbols.
Guido van Rossum <guido@python.org>
parents:
4374
diff
changeset
|
24 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
21766
diff
changeset
|
25 PyAPI_FUNC(PyThread_type_lock) PyThread_allocate_lock(void); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
21766
diff
changeset
|
26 PyAPI_FUNC(void) PyThread_free_lock(PyThread_type_lock); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
21766
diff
changeset
|
27 PyAPI_FUNC(int) PyThread_acquire_lock(PyThread_type_lock, int); |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
28 #define WAIT_LOCK 1 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
29 #define NOWAIT_LOCK 0 |
|
60598
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
30 |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
31 /* PY_TIMEOUT_T is the integral type used to specify timeouts when waiting |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
32 on a lock (see PyThread_acquire_lock_timed() below). |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
33 PY_TIMEOUT_MAX is the highest usable value (in microseconds) of that |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
34 type, and depends on the system threading API. |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
35 |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
36 NOTE: this isn't the same value as `_thread.TIMEOUT_MAX`. The _thread |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
37 module exposes a higher-level API, with timeouts expressed in seconds |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
38 and floating-point numbers allowed. |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
39 */ |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
40 #if defined(HAVE_LONG_LONG) |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
41 #define PY_TIMEOUT_T PY_LONG_LONG |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
42 #define PY_TIMEOUT_MAX PY_LLONG_MAX |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
43 #else |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
44 #define PY_TIMEOUT_T long |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
45 #define PY_TIMEOUT_MAX LONG_MAX |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
46 #endif |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
47 |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
48 /* In the NT API, the timeout is a DWORD and is expressed in milliseconds */ |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
49 #if defined (NT_THREADS) |
|
64660
5f3a64564c51
Issue #9318: Use Py_LL for old compiler.
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents:
60598
diff
changeset
|
50 #if (Py_LL(0xFFFFFFFF) * 1000 < PY_TIMEOUT_MAX) |
|
60598
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
51 #undef PY_TIMEOUT_MAX |
|
64660
5f3a64564c51
Issue #9318: Use Py_LL for old compiler.
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents:
60598
diff
changeset
|
52 #define PY_TIMEOUT_MAX (Py_LL(0xFFFFFFFF) * 1000) |
|
60598
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
53 #endif |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
54 #endif |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
55 |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
56 /* If microseconds == 0, the call is non-blocking: it returns immediately |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
57 even when the lock can't be acquired. |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
58 If microseconds > 0, the call waits up to the specified duration. |
|
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
59 If microseconds < 0, the call waits until success (or abnormal failure) |
|
66946
b750c45a772c
Issue #8844: Regular and recursive lock acquisitions can now be interrupted
Antoine Pitrou <solipsis@pitrou.net>
parents:
64660
diff
changeset
|
60 |
|
60598
01d1fd775d16
Issue #7316: the acquire() method of lock objects in the :mod:`threading`
Antoine Pitrou <solipsis@pitrou.net>
parents:
59089
diff
changeset
|
61 microseconds must be less than PY_TIMEOUT_MAX. Behaviour otherwise is |
|
66946
b750c45a772c
Issue #8844: Regular and recursive lock acquisitions can now be interrupted
Antoine Pitrou <solipsis@pitrou.net>
parents:
64660
diff
changeset
|
62 undefined. |
|
b750c45a772c
Issue #8844: Regular and recursive lock acquisitions can now be interrupted
Antoine Pitrou <solipsis@pitrou.net>
parents:
64660
diff
changeset
|
63 |
|
b750c45a772c
Issue #8844: Regular and recursive lock acquisitions can now be interrupted
Antoine Pitrou <solipsis@pitrou.net>
parents:
64660
diff
changeset
|
64 If intr_flag is true and the acquire is interrupted by a signal, then the |
|
b750c45a772c
Issue #8844: Regular and recursive lock acquisitions can now be interrupted
Antoine Pitrou <solipsis@pitrou.net>
parents:
64660
diff
changeset
|
65 call will return PY_LOCK_INTR. The caller may reattempt to acquire the |
|
b750c45a772c
Issue #8844: Regular and recursive lock acquisitions can now be interrupted
Antoine Pitrou <solipsis@pitrou.net>
parents:
64660
diff
changeset
|
66 lock. |
|
b750c45a772c
Issue #8844: Regular and recursive lock acquisitions can now be interrupted
Antoine Pitrou <solipsis@pitrou.net>
parents:
64660
diff
changeset
|
67 */ |
|
b750c45a772c
Issue #8844: Regular and recursive lock acquisitions can now be interrupted
Antoine Pitrou <solipsis@pitrou.net>
parents:
64660
diff
changeset
|
68 PyAPI_FUNC(PyLockStatus) PyThread_acquire_lock_timed(PyThread_type_lock, |
|
b750c45a772c
Issue #8844: Regular and recursive lock acquisitions can now be interrupted
Antoine Pitrou <solipsis@pitrou.net>
parents:
64660
diff
changeset
|
69 PY_TIMEOUT_T microseconds, |
|
b750c45a772c
Issue #8844: Regular and recursive lock acquisitions can now be interrupted
Antoine Pitrou <solipsis@pitrou.net>
parents:
64660
diff
changeset
|
70 int intr_flag); |
|
b750c45a772c
Issue #8844: Regular and recursive lock acquisitions can now be interrupted
Antoine Pitrou <solipsis@pitrou.net>
parents:
64660
diff
changeset
|
71 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
21766
diff
changeset
|
72 PyAPI_FUNC(void) PyThread_release_lock(PyThread_type_lock); |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
73 |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
28694
diff
changeset
|
74 PyAPI_FUNC(size_t) PyThread_get_stacksize(void); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
28694
diff
changeset
|
75 PyAPI_FUNC(int) PyThread_set_stacksize(size_t); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
28694
diff
changeset
|
76 |
|
28694
a4154dd5939a
New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24752
diff
changeset
|
77 /* Thread Local Storage (TLS) API */ |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
21766
diff
changeset
|
78 PyAPI_FUNC(int) PyThread_create_key(void); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
21766
diff
changeset
|
79 PyAPI_FUNC(void) PyThread_delete_key(int); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
21766
diff
changeset
|
80 PyAPI_FUNC(int) PyThread_set_key_value(int, void *); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
21766
diff
changeset
|
81 PyAPI_FUNC(void *) PyThread_get_key_value(int); |
|
28694
a4154dd5939a
New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24752
diff
changeset
|
82 PyAPI_FUNC(void) PyThread_delete_key_value(int key); |
|
5405
b7871ca930ad
Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
5194
diff
changeset
|
83 |
|
47665
71cb7ea4f110
Merged revisions 64212 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
39442
diff
changeset
|
84 /* Cleanup after a fork */ |
|
71cb7ea4f110
Merged revisions 64212 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
39442
diff
changeset
|
85 PyAPI_FUNC(void) PyThread_ReInitTLS(void); |
|
71cb7ea4f110
Merged revisions 64212 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
39442
diff
changeset
|
86 |
|
1047
6b5a34db21fe
Added C++ support in thread.h; don't use signals if not strictly
Sjoerd Mullender <sjoerd@acm.org>
parents:
961
diff
changeset
|
87 #ifdef __cplusplus |
|
6b5a34db21fe
Added C++ support in thread.h; don't use signals if not strictly
Sjoerd Mullender <sjoerd@acm.org>
parents:
961
diff
changeset
|
88 } |
|
6b5a34db21fe
Added C++ support in thread.h; don't use signals if not strictly
Sjoerd Mullender <sjoerd@acm.org>
parents:
961
diff
changeset
|
89 #endif |
|
6b5a34db21fe
Added C++ support in thread.h; don't use signals if not strictly
Sjoerd Mullender <sjoerd@acm.org>
parents:
961
diff
changeset
|
90 |
|
10456
3f213a8fc04e
Conform to standard boilerplate.
Guido van Rossum <guido@python.org>
parents:
9679
diff
changeset
|
91 #endif /* !Py_PYTHREAD_H */ |
