Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
375e3022
Commit
375e3022
authored
Apr 09, 2002
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update to use the new \csimplemacro macro
parent
79bf99c5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
22 deletions
+24
-22
Doc/api/init.tex
Doc/api/init.tex
+19
-17
Doc/ext/extending.tex
Doc/ext/extending.tex
+5
-5
No files found.
Doc/api/init.tex
View file @
375e3022
...
...
@@ -391,12 +391,13 @@ Py_BEGIN_ALLOW_THREADS
Py
_
END
_
ALLOW
_
THREADS
\end{verbatim}
The
\code
{
Py
_
BEGIN
_
ALLOW
_
THREADS
}
\ttindex
{
Py
_
BEGIN
_
ALLOW
_
THREADS
}
macro
opens a new block and declares a hidden local variable; the
\code
{
Py
_
END
_
ALLOW
_
THREADS
}
\ttindex
{
Py
_
END
_
ALLOW
_
THREADS
}
macro closes
the block. Another advantage of using these two macros is that when
Python is compiled without thread support, they are defined empty,
thus saving the thread state and lock manipulations.
The
\csimplemacro
{
Py
_
BEGIN
_
ALLOW
_
THREADS
}
\ttindex
{
Py
_
BEGIN
_
ALLOW
_
THREADS
}
macro opens a new block and declares a hidden local variable; the
\csimplemacro
{
Py
_
END
_
ALLOW
_
THREADS
}
\ttindex
{
Py
_
END
_
ALLOW
_
THREADS
}
macro closes the block. Another advantage of using these two macros
is that when Python is compiled without thread support, they are
defined empty, thus saving the thread state and lock manipulations.
When thread support is enabled, the block above expands to the
following code:
...
...
@@ -574,30 +575,31 @@ look for example usage in the Python source distribution.
This macro expands to
\samp
{
\{
PyThreadState *
_
save;
_
save = PyEval
_
SaveThread();
}
.
Note that it contains an opening brace; it must be matched with a
following
\c
ode
{
Py
_
END
_
ALLOW
_
THREADS
}
macro. See above for furthe
r
discussion of this macro. It is a no-op when thread support is
disabled at compile time.
following
\c
simplemacro
{
Py
_
END
_
ALLOW
_
THREADS
}
macro. See above fo
r
further discussion of this macro. It is a no-op when thread support
is
disabled at compile time.
\end{csimplemacrodesc}
\begin{csimplemacrodesc}
{
Py
_
END
_
ALLOW
_
THREADS
}
This macro expands to
\samp
{
PyEval
_
RestoreThread(
_
save);
\}
}
.
Note that it contains a closing brace; it must be matched with an
earlier
\c
ode
{
Py
_
BEGIN
_
ALLOW
_
THREADS
}
macro. See above for furthe
r
discussion of this macro. It is a no-op when thread support is
disabled at compile time.
earlier
\c
simplemacro
{
Py
_
BEGIN
_
ALLOW
_
THREADS
}
macro. See above fo
r
further discussion of this macro. It is a no-op when thread support
is
disabled at compile time.
\end{csimplemacrodesc}
\begin{csimplemacrodesc}
{
Py
_
BLOCK
_
THREADS
}
This macro expands to
\samp
{
PyEval
_
RestoreThread(
_
save);
}
: it is
equivalent to
\code
{
Py
_
END
_
ALLOW
_
THREADS
}
without the closing brace.
It is a no-op when thread support is disabled at compile time.
equivalent to
\csimplemacro
{
Py
_
END
_
ALLOW
_
THREADS
}
without the
closing brace. It is a no-op when thread support is disabled at
compile time.
\end{csimplemacrodesc}
\begin{csimplemacrodesc}
{
Py
_
UNBLOCK
_
THREADS
}
This macro expands to
\samp
{_
save = PyEval
_
SaveThread();
}
: it is
equivalent to
\c
ode
{
Py
_
BEGIN
_
ALLOW
_
THREADS
}
without the opening
brace and variable declaration. It is a no-op when thread support
is disabled at compile time.
equivalent to
\c
simplemacro
{
Py
_
BEGIN
_
ALLOW
_
THREADS
}
without the
opening brace and variable declaration. It is a no-op when thread
support
is disabled at compile time.
\end{csimplemacrodesc}
All of the following functions are only available when thread support
...
...
Doc/ext/extending.tex
View file @
375e3022
...
...
@@ -1068,11 +1068,11 @@ involving threads. Normally, multiple threads in the Python
interpreter can't get in each other's way, because there is a global
lock protecting Python's entire object space. However, it is possible
to temporarily release this lock using the macro
\c
ode
{
Py
_
BEGIN
_
ALLOW
_
THREADS
}
, and to re-acquire it using
\c
ode
{
Py
_
END
_
ALLOW
_
THREADS
}
. This is common around blocking I/O
calls, to let other threads use the processor while waiting for the I/O to
complete. Obviously, the following function has the same problem as
the previous one:
\c
simplemacro
{
Py
_
BEGIN
_
ALLOW
_
THREADS
}
, and to re-acquire it using
\c
simplemacro
{
Py
_
END
_
ALLOW
_
THREADS
}
. This is common around blocking
I/O calls, to let other threads use the processor while waiting for
the I/O to complete. Obviously, the following function has the same
problem as
the previous one:
\begin{verbatim}
bug(PyObject *list)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment