Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bf5a6d2

Browse files
committed
Fixed tons of small markup problems.
1 parent 3fce883 commit bf5a6d2

1 file changed

Lines changed: 74 additions & 69 deletions

File tree

Doc/lib/libthreading.tex

Lines changed: 74 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
\section{\module{threading} ---
2-
Higher-level threading interfaces.}
3-
\declaremodule{standard}{threading}
2+
Higher-level threading interface}
43

5-
\modulesynopsis{Higher-level threading interfaces.}
4+
\declaremodule{standard}{threading}
5+
\modulesynopsis{Higher-level threading interface.}
66

77

88
This module constructs higher-level threading interfaces on top of the
@@ -85,7 +85,8 @@ \section{\module{threading} ---
8585

8686
All of the methods described below are executed atomically.
8787

88-
\subsection{Lock Objects}
88+
89+
\subsection{Lock Objects \label{lock-objects}}
8990

9091
A primitive lock is a synchronization primitive that is not owned
9192
by a particular thread when locked. In Python, it is currently
@@ -109,7 +110,7 @@ \subsection{Lock Objects}
109110

110111
All methods are executed atomically.
111112

112-
\begin{methoddesc}{acquire}{blocking=1}
113+
\begin{methoddesc}{acquire}{\optional{blocking\code{ = 1}}}
113114
Acquire a lock, blocking or non-blocking.
114115

115116
When invoked without arguments, block until the lock is
@@ -137,7 +138,8 @@ \subsection{Lock Objects}
137138
There is no return value.
138139
\end{methoddesc}
139140

140-
\subsection{RLock Objects}
141+
142+
\subsection{RLock Objects \label{rlock-objects}}
141143

142144
A reentrant lock is a synchronization primitive that may be
143145
acquired multiple times by the same thread. Internally, it uses
@@ -153,7 +155,7 @@ \subsection{RLock Objects}
153155
outermost pair) resets the lock to unlocked and allows another
154156
thread blocked in \method{acquire()} to proceed.
155157

156-
\begin{methoddesc}{acquire}{blocking=1}
158+
\begin{methoddesc}{acquire}{\optional{blocking\code{ = 1}}}
157159
Acquire a lock, blocking or non-blocking.
158160

159161
When invoked without arguments: if this thread already owns
@@ -189,7 +191,8 @@ \subsection{RLock Objects}
189191
There is no return value.
190192
\end{methoddesc}
191193

192-
\subsection{Condition Objects}
194+
195+
\subsection{Condition Objects \label{condition-objects}}
193196

194197
A condition variable is always associated with some kind of lock;
195198
this can be passed in or one will be created by default. (Passing
@@ -248,11 +251,11 @@ \subsection{Condition Objects}
248251
adding one item to the buffer only needs to wake up one consumer
249252
thread.
250253

251-
\begin{classdesc}{Condition}{lock=None}
252-
If the \var{lock} argument is given and not \code{None}, it must be a \class{Lock}
253-
or \class{RLock} object, and it is used as the underlying lock.
254-
Otherwise, a new \class{RLock} object is created and used as the
255-
underlying lock.
254+
\begin{classdesc}{Condition}{\optional{lock}}
255+
If the \var{lock} argument is given and not \code{None}, it must be a
256+
\class{Lock} or \class{RLock} object, and it is used as the underlying
257+
lock. Otherwise, a new \class{RLock} object is created and used as
258+
the underlying lock.
256259
\end{classdesc}
257260

258261
\begin{methoddesc}{acquire}{*args}
@@ -267,7 +270,7 @@ \subsection{Condition Objects}
267270
lock; there is no return value.
268271
\end{methoddesc}
269272

270-
\begin{methoddesc}{wait}{timeout=None}
273+
\begin{methoddesc}{wait}{\optional{timeout}}
271274
Wait until notified or until a timeout occurs.
272275
This must only be called when the calling thread has acquired the
273276
lock.
@@ -278,17 +281,17 @@ \subsection{Condition Objects}
278281
timeout occurs. Once awakened or timed out, it re-acquires the lock
279282
and returns.
280283

281-
When the timeout argument is present and not \code{None}, it should be a
282-
floating point number specifying a timeout for the operation in
283-
seconds (or fractions thereof).
284+
When the \var{timeout} argument is present and not \code{None}, it
285+
should be a floating point number specifying a timeout for the
286+
operation in seconds (or fractions thereof).
284287

285-
When the underlying lock is an \class{RLock}, it is not released using its
286-
\method{release()} method, since this may not actually unlock the lock
287-
when it was acquired multiple times recursively. Instead, an
288-
internal interface of the \class{RLock} class is used, which really unlocks it
289-
even when it has been recursively acquired several times. Another
290-
internal interface is then used to restore the recursion level when
291-
the lock is reacquired.
288+
When the underlying lock is an \class{RLock}, it is not released using
289+
its \method{release()} method, since this may not actually unlock the
290+
lock when it was acquired multiple times recursively. Instead, an
291+
internal interface of the \class{RLock} class is used, which really
292+
unlocks it even when it has been recursively acquired several times.
293+
Another internal interface is then used to restore the recursion level
294+
when the lock is reacquired.
292295
\end{methoddesc}
293296

294297
\begin{methoddesc}{notify}{}
@@ -314,25 +317,26 @@ \subsection{Condition Objects}
314317
\method{notify()}, but wakes up all waiting threads instead of one.
315318
\end{methoddesc}
316319

317-
\subsection{Semaphore Objects}
320+
321+
\subsection{Semaphore Objects \label{semaphore-objects}}
318322

319323
This is one of the oldest synchronization primitives in the history of
320324
computer science, invented by the early Dutch computer scientist
321-
Edsger W. Dijkstra (he used \method{P()} and \method{V()} instead of \method{acquire()}
322-
and \method{release()}).
325+
Edsger W. Dijkstra (he used \method{P()} and \method{V()} instead of
326+
\method{acquire()} and \method{release()}).
323327

324328
A semaphore manages an internal counter which is decremented by each
325329
\method{acquire()} call and incremented by each \method{release()}
326330
call. The counter can never go below zero; when \method{acquire()}
327331
finds that it is zero, it blocks, waiting until some other thread
328332
calls \method{release()}.
329333

330-
\begin{classdesc}{Semaphore}{value=1}
334+
\begin{classdesc}{Semaphore}{\optional{value}}
331335
The optional argument gives the initial value for the internal
332-
counter; it defaults to 1.
336+
counter; it defaults to \code{1}.
333337
\end{classdesc}
334338

335-
\begin{methoddesc}{acquire}{blocking=1}
339+
\begin{methoddesc}{acquire}{\optional{blocking}}
336340
Acquire a semaphore.
337341

338342
When invoked without arguments: if the internal counter is larger than
@@ -345,13 +349,13 @@ \subsection{Semaphore Objects}
345349
threads are awakened should not be relied on. There is no return
346350
value in this case.
347351

348-
When invoked with the \var{blocking} argument set to true, do the same
349-
thing as when called without arguments, and return true.
352+
When invoked with \var{blocking} set to true, do the same thing as
353+
when called without arguments, and return true.
350354

351-
When invoked with the \var{blocking} argument set to false, do not
352-
block. If a call without an argument would block, return false
353-
immediately; otherwise, do the same thing as when called without
354-
arguments, and return true.
355+
When invoked with \var{blocking} set to false, do not block. If a
356+
call without an argument would block, return false immediately;
357+
otherwise, do the same thing as when called without arguments, and
358+
return true.
355359
\end{methoddesc}
356360

357361
\begin{methoddesc}{release}{}
@@ -361,7 +365,8 @@ \subsection{Semaphore Objects}
361365
than zero again, wake up that thread.
362366
\end{methoddesc}
363367

364-
\subsection{Event Objects}
368+
369+
\subsection{Event Objects \label{event-objects}}
365370

366371
This is one of the simplest mechanisms for communication between
367372
threads: one thread signals an event and one or more other thread
@@ -393,7 +398,7 @@ \subsection{Event Objects}
393398
called to set the internal flag to true again.
394399
\end{methoddesc}
395400

396-
\begin{methoddesc}{wait}{timeout=None}
401+
\begin{methoddesc}{wait}{\optional{timeout}}
397402
Block until the internal flag is true.
398403
If the internal flag is true on entry, return immediately. Otherwise,
399404
block until another thread calls \method{set()} to set the flag to
@@ -404,41 +409,42 @@ \subsection{Event Objects}
404409
seconds (or fractions thereof).
405410
\end{methoddesc}
406411

407-
\subsection{Thread Objects}
412+
413+
\subsection{Thread Objects \label{thread-objects}}
408414

409415
This class represents an activity that is run in a separate thread
410416
of control. There are two ways to specify the activity: by
411417
passing a callable object to the constructor, or by overriding the
412418
\method{run()} method in a subclass. No other methods (except for the
413419
constructor) should be overridden in a subclass. In other words,
414-
\emph{only} override the \method{__init__()} and \method{run()} methods of this class.
415-
420+
\emph{only} override the \method{__init__()} and \method{run()}
421+
methods of this class.
416422

417423
Once a thread object is created, its activity must be started by
418-
calling the thread's \method{start()} method. This invokes the \method{run()}
419-
method in a separate thread of control.
424+
calling the thread's \method{start()} method. This invokes the
425+
\method{run()} method in a separate thread of control.
420426

421427
Once the thread's activity is started, the thread is considered
422428
'alive' and 'active' (these concepts are almost, but not quite
423429
exactly, the same; their definition is intentionally somewhat
424-
vague). It stops being alive and active when its \method{run()} method
425-
terminates -- either normally, or by raising an unhandled
430+
vague). It stops being alive and active when its \method{run()}
431+
method terminates -- either normally, or by raising an unhandled
426432
exception. The \method{isAlive()} method tests whether the thread is
427433
alive.
428434

429-
Other threads can call a thread's \method{join()} method. This blocks the
430-
calling thread until the thread whose \method{join()} method is called
431-
is terminated.
435+
Other threads can call a thread's \method{join()} method. This blocks
436+
the calling thread until the thread whose \method{join()} method is
437+
called is terminated.
432438

433439
A thread has a name. The name can be passed to the constructor,
434-
set with the \method{setName()} method, and retrieved with the \method{getName()}
435-
method.
440+
set with the \method{setName()} method, and retrieved with the
441+
\method{getName()} method.
436442

437443
A thread can be flagged as a ``daemon thread''. The significance
438444
of this flag is that the entire Python program exits when only
439445
daemon threads are left. The initial value is inherited from the
440-
creating thread. The flag can be set with the \method{setDaemon()} method
441-
and retrieved with the \method{getDaemon()} method.
446+
creating thread. The flag can be set with the \method{setDaemon()}
447+
method and retrieved with the \method{getDaemon()} method.
442448

443449
There is a ``main thread'' object; this corresponds to the
444450
initial thread of control in the Python program. It is not a
@@ -449,38 +455,37 @@ \subsection{Thread Objects}
449455
threads''. These are threads of control started outside the
450456
threading module, e.g. directly from C code. Dummy thread objects
451457
have limited functionality; they are always considered alive,
452-
active, and daemonic, and cannot be \method{join()}ed. They are never
458+
active, and daemonic, and cannot be \method{join()}ed. They are never
453459
deleted, since it is impossible to detect the termination of alien
454460
threads.
455461

456462

457463
\begin{classdesc}{Thread}{group=None, target=None, name=None,
458-
args=(), kwargs={}}
464+
args=(), kwargs=\{\}}
459465
This constructor should always be called with keyword
460466
arguments. Arguments are:
461467

462-
group
463-
Should be None; reserved for future extension when a
464-
ThreadGroup class is implemented.
468+
\var{group}
469+
Should be \code{None}; reserved for future extension when a
470+
\class{ThreadGroup} class is implemented.
465471

466-
target
472+
\var{target}
467473
Callable object to be invoked by the \method{run()} method.
468-
Defaults to None, meaning nothing is called.
474+
Defaults to \code{None}, meaning nothing is called.
469475

470-
name
471-
The thread name. By default, a unique name is constructed
472-
of the form ``Thread-N'' where N is a small decimal
473-
number.
476+
\var{name}
477+
The thread name. By default, a unique name is constructed of the form
478+
``Thread-\var{N}'' where \var{N} is a small decimal number.
474479

475-
args
476-
Argument tuple for the target invocation. Defaults to ().
480+
\var{args}
481+
Argument tuple for the target invocation. Defaults to \code{()}.
477482

478-
kwargs
483+
\var{kwargs}
479484
Keyword argument dictionary for the target invocation.
480-
Defaults to {}.
485+
Defaults to \code{\{\}}.
481486

482487
If the subclass overrides the constructor, it must make sure
483-
to invoke the base class constructor (Thread.__init__())
488+
to invoke the base class constructor (\code{Thread.__init__()})
484489
before doing anything else to the thread.
485490
\end{classdesc}
486491

@@ -507,7 +512,7 @@ \subsection{Thread Objects}
507512
\end{methoddesc}
508513

509514

510-
\begin{methoddesc}{join}{timeout=None}
515+
\begin{methoddesc}{join}{\optional{timeout}}
511516
Wait until the thread terminates.
512517
This blocks the calling thread until the thread whose \method{join()}
513518
method is called terminates -- either normally or through an

0 commit comments

Comments
 (0)