Commit d00681ce authored by Guido van Rossum's avatar Guido van Rossum

Change title to {Python/C API Reference Manual}; remove \bcode \ecode

which appears to be out of fashion in this file.
parent 39cb6963
\documentstyle[twoside,11pt,myformat]{report} \documentstyle[twoside,11pt,myformat]{report}
\title{Python/C API Reference} \title{Python/C API Reference Manual}
\input{boilerplate} \input{boilerplate}
...@@ -1058,13 +1058,13 @@ already imported.) ...@@ -1058,13 +1058,13 @@ already imported.)
This is the structure type definition for frozen module descriptors, This is the structure type definition for frozen module descriptors,
as generated by the \code{freeze} utility (see \file{Tools/freeze/} in as generated by the \code{freeze} utility (see \file{Tools/freeze/} in
the Python source distribution). Its definition is: the Python source distribution). Its definition is:
\bcode\begin{verbatim} \begin{verbatim}
struct _frozen { struct _frozen {
char *name; char *name;
unsigned char *code; unsigned char *code;
int size; int size;
}; };
\end{verbatim}\ecode \end{verbatim}
\end{ctypedesc} \end{ctypedesc}
\begin{cvardesc}{struct _frozen *}{PyImport_FrozenModules} \begin{cvardesc}{struct _frozen *}{PyImport_FrozenModules}
...@@ -2047,21 +2047,21 @@ the current thread state must be manipulated explicitly. ...@@ -2047,21 +2047,21 @@ the current thread state must be manipulated explicitly.
This is easy enough in most cases. Most code manipulating the global This is easy enough in most cases. Most code manipulating the global
interpreter lock has the following simple structure: interpreter lock has the following simple structure:
\bcode\begin{verbatim} \begin{verbatim}
Save the thread state in a local variable. Save the thread state in a local variable.
Release the interpreter lock. Release the interpreter lock.
...Do some blocking I/O operation... ...Do some blocking I/O operation...
Reacquire the interpreter lock. Reacquire the interpreter lock.
Restore the thread state from the local variable. Restore the thread state from the local variable.
\end{verbatim}\ecode \end{verbatim}
This is so common that a pair of macros exists to simplify it: This is so common that a pair of macros exists to simplify it:
\bcode\begin{verbatim} \begin{verbatim}
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
...Do some blocking I/O operation... ...Do some blocking I/O operation...
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
\end{verbatim}\ecode \end{verbatim}
The BEGIN macro opens a new block and declares a hidden local The BEGIN macro opens a new block and declares a hidden local
variable; the END macro closes the block. Another advantage of using variable; the END macro closes the block. Another advantage of using
...@@ -2072,19 +2072,19 @@ manipulations. ...@@ -2072,19 +2072,19 @@ manipulations.
When thread support is enabled, the block above expands to the When thread support is enabled, the block above expands to the
following code: following code:
\bcode\begin{verbatim} \begin{verbatim}
{ {
PyThreadState *_save; PyThreadState *_save;
_save = PyEval_SaveThread(); _save = PyEval_SaveThread();
...Do some blocking I/O operation... ...Do some blocking I/O operation...
PyEval_RestoreThread(_save); PyEval_RestoreThread(_save);
} }
\end{verbatim}\ecode \end{verbatim}
Using even lower level primitives, we can get roughly the same effect Using even lower level primitives, we can get roughly the same effect
as follows: as follows:
\bcode\begin{verbatim} \begin{verbatim}
{ {
PyThreadState *_save; PyThreadState *_save;
_save = PyThreadState_Swap(NULL); _save = PyThreadState_Swap(NULL);
...@@ -2093,7 +2093,7 @@ as follows: ...@@ -2093,7 +2093,7 @@ as follows:
PyEval_AcquireLock(); PyEval_AcquireLock();
PyThreadState_Swap(_save); PyThreadState_Swap(_save);
} }
\end{verbatim}\ecode \end{verbatim}
There are some subtle differences; in particular, There are some subtle differences; in particular,
\code{PyEval_RestoreThread()} saves and restores the value of the \code{PyEval_RestoreThread()} saves and restores the value of the
......
\documentstyle[twoside,11pt,myformat]{report} \documentstyle[twoside,11pt,myformat]{report}
\title{Python/C API Reference} \title{Python/C API Reference Manual}
\input{boilerplate} \input{boilerplate}
...@@ -1058,13 +1058,13 @@ already imported.) ...@@ -1058,13 +1058,13 @@ already imported.)
This is the structure type definition for frozen module descriptors, This is the structure type definition for frozen module descriptors,
as generated by the \code{freeze} utility (see \file{Tools/freeze/} in as generated by the \code{freeze} utility (see \file{Tools/freeze/} in
the Python source distribution). Its definition is: the Python source distribution). Its definition is:
\bcode\begin{verbatim} \begin{verbatim}
struct _frozen { struct _frozen {
char *name; char *name;
unsigned char *code; unsigned char *code;
int size; int size;
}; };
\end{verbatim}\ecode \end{verbatim}
\end{ctypedesc} \end{ctypedesc}
\begin{cvardesc}{struct _frozen *}{PyImport_FrozenModules} \begin{cvardesc}{struct _frozen *}{PyImport_FrozenModules}
...@@ -2047,21 +2047,21 @@ the current thread state must be manipulated explicitly. ...@@ -2047,21 +2047,21 @@ the current thread state must be manipulated explicitly.
This is easy enough in most cases. Most code manipulating the global This is easy enough in most cases. Most code manipulating the global
interpreter lock has the following simple structure: interpreter lock has the following simple structure:
\bcode\begin{verbatim} \begin{verbatim}
Save the thread state in a local variable. Save the thread state in a local variable.
Release the interpreter lock. Release the interpreter lock.
...Do some blocking I/O operation... ...Do some blocking I/O operation...
Reacquire the interpreter lock. Reacquire the interpreter lock.
Restore the thread state from the local variable. Restore the thread state from the local variable.
\end{verbatim}\ecode \end{verbatim}
This is so common that a pair of macros exists to simplify it: This is so common that a pair of macros exists to simplify it:
\bcode\begin{verbatim} \begin{verbatim}
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
...Do some blocking I/O operation... ...Do some blocking I/O operation...
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
\end{verbatim}\ecode \end{verbatim}
The BEGIN macro opens a new block and declares a hidden local The BEGIN macro opens a new block and declares a hidden local
variable; the END macro closes the block. Another advantage of using variable; the END macro closes the block. Another advantage of using
...@@ -2072,19 +2072,19 @@ manipulations. ...@@ -2072,19 +2072,19 @@ manipulations.
When thread support is enabled, the block above expands to the When thread support is enabled, the block above expands to the
following code: following code:
\bcode\begin{verbatim} \begin{verbatim}
{ {
PyThreadState *_save; PyThreadState *_save;
_save = PyEval_SaveThread(); _save = PyEval_SaveThread();
...Do some blocking I/O operation... ...Do some blocking I/O operation...
PyEval_RestoreThread(_save); PyEval_RestoreThread(_save);
} }
\end{verbatim}\ecode \end{verbatim}
Using even lower level primitives, we can get roughly the same effect Using even lower level primitives, we can get roughly the same effect
as follows: as follows:
\bcode\begin{verbatim} \begin{verbatim}
{ {
PyThreadState *_save; PyThreadState *_save;
_save = PyThreadState_Swap(NULL); _save = PyThreadState_Swap(NULL);
...@@ -2093,7 +2093,7 @@ as follows: ...@@ -2093,7 +2093,7 @@ as follows:
PyEval_AcquireLock(); PyEval_AcquireLock();
PyThreadState_Swap(_save); PyThreadState_Swap(_save);
} }
\end{verbatim}\ecode \end{verbatim}
There are some subtle differences; in particular, There are some subtle differences; in particular,
\code{PyEval_RestoreThread()} saves and restores the value of the \code{PyEval_RestoreThread()} saves and restores the value of the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment