Skip to content

Commit a4612cc

Browse files
authored
Add backticks and crossreferences to parallel/event docs (#19411)
1 parent 8dd8ea9 commit a4612cc

13 files changed

+185
-156
lines changed

base/asyncmap.jl

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ If `ntasks` is unspecified, uses `max(100, nworkers())` tasks.
1111
For multiple collection arguments, apply `f` elementwise.
1212
Output is collected into `results`.
1313
14-
Note: `next(::AsyncCollector, state) -> (nothing, state)`
14+
!!! note
15+
`next(::AsyncCollector, state) -> (nothing, state)`
1516
16-
Note: `for task in AsyncCollector(f, results, c...) end` is equivalent to
17-
`map!(f, results, c...)`.
17+
!!! note
18+
`for task in AsyncCollector(f, results, c...) end` is equivalent to
19+
`map!(f, results, c...)`.
1820
"""
1921
type AsyncCollector
2022
f
@@ -154,10 +156,12 @@ end
154156
155157
Apply `f` to each element of `c` using at most `ntasks` asynchronous tasks.
156158
If `ntasks` is unspecified, uses `max(100, nworkers())` tasks.
157-
For multiple collection arguments, apply f elementwise.
159+
For multiple collection arguments, apply `f` elementwise.
158160
Results are returned by the iterator as they become available.
159-
Note: `collect(AsyncGenerator(f, c...; ntasks=1))` is equivalent to
160-
`map(f, c...)`.
161+
162+
!!! note
163+
`collect(AsyncGenerator(f, c...; ntasks=1))` is equivalent to
164+
`map(f, c...)`.
161165
"""
162166
type AsyncGenerator
163167
collector::AsyncCollector
@@ -220,22 +224,22 @@ length(itr::AsyncGenerator) = length(itr.collector.enumerator)
220224
221225
Transform collection `c` by applying `@async f` to each element.
222226
223-
For multiple collection arguments, apply f elementwise.
227+
For multiple collection arguments, apply `f` elementwise.
224228
"""
225229
asyncmap(f, c...) = collect(AsyncGenerator(f, c...))
226230

227231

228232
"""
229233
asyncmap!(f, c)
230234
231-
In-place version of `asyncmap()`.
235+
In-place version of [`asyncmap()`](:func:`asyncmap`).
232236
"""
233237
asyncmap!(f, c) = (for x in AsyncCollector(f, c, c) end; c)
234238

235239

236240
"""
237241
asyncmap!(f, results, c...)
238242
239-
Like `asyncmap()`, but stores output in `results` rather returning a collection.
243+
Like [`asyncmap()`](:func:`asyncmap`), but stores output in `results` rather returning a collection.
240244
"""
241245
asyncmap!(f, r, c1, c...) = (for x in AsyncCollector(f, r, c1, c...) end; r)

base/channels.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ abstract AbstractChannel
66
Channel{T}(sz::Int)
77
88
Constructs a `Channel` with an internal buffer that can hold a maximum of `sz` objects
9-
of type `T`. `put!` calls on a full channel block until an object is removed with `take!`.
9+
of type `T`.
10+
[`put!`](:func:`put!`) calls on a full channel block until an object is removed with [`take!`](:func:`take!`).
1011
1112
`Channel(0)` constructs an unbuffered channel. `put!` blocks until a matching `take!` is called.
1213
And vice-versa.
@@ -64,8 +65,8 @@ isbuffered(c::Channel) = c.sz_max==0 ? false : true
6465
6566
Closes a channel. An exception is thrown by:
6667
67-
* `put!` on a closed channel.
68-
* `take!` and `fetch` on an empty, closed channel.
68+
* [`put!`](:func:`put!`) on a closed channel.
69+
* [`take!`](:func:`take!`) and [`fetch`](:func:`fetch`) on an empty, closed channel.
6970
"""
7071
function close(c::Channel)
7172
c.state = :closed
@@ -84,7 +85,7 @@ end
8485
8586
Appends an item `v` to the channel `c`. Blocks if the channel is full.
8687
87-
For unbuffered channels, blocks until a `take!` is performed by a different
88+
For unbuffered channels, blocks until a [`take!`](:func:`take!`) is performed by a different
8889
task.
8990
"""
9091
function put!(c::Channel, v)
@@ -130,9 +131,9 @@ fetch_unbuffered(c::Channel) = throw(ErrorException("`fetch` is not supported on
130131
"""
131132
take!(c::Channel)
132133
133-
Removes and returns a value from a `Channel`. Blocks until data is available.
134+
Removes and returns a value from a [`Channel`](:obj:`Channel`). Blocks until data is available.
134135
135-
For unbuffered channels, blocks until a `put!` is performed by a different
136+
For unbuffered channels, blocks until a [`put!`](:func:`put!`) is performed by a different
136137
task.
137138
"""
138139
take!(c::Channel) = isbuffered(c) ? take_buffered(c) : take_unbuffered(c)
@@ -166,11 +167,11 @@ end
166167
"""
167168
isready(c::Channel)
168169
169-
Determine whether a `Channel` has a value stored to it. Returns
170+
Determine whether a [`Channel`](:obj:`Channel`) has a value stored to it. Returns
170171
immediately, does not block.
171172
172173
For unbuffered channels returns `true` if there are tasks waiting
173-
on a `put!`.
174+
on a [`put!`](:func:`put!`).
174175
"""
175176
isready(c::Channel) = n_avail(c) > 0
176177
n_avail(c::Channel) = isbuffered(c) ? length(c.data) : n_waiters(c.cond_put)

base/event.jl

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"""
66
Condition()
77
8-
Create an edge-triggered event source that tasks can wait for. Tasks that call `wait` on a
9-
`Condition` are suspended and queued. Tasks are woken up when `notify` is later called on
10-
the `Condition`. Edge triggering means that only tasks waiting at the time `notify` is
8+
Create an edge-triggered event source that tasks can wait for. Tasks that call [`wait`](:func:`wait`) on a
9+
`Condition` are suspended and queued. Tasks are woken up when [`notify`](:func:`notify`) is later called on
10+
the `Condition`. Edge triggering means that only tasks waiting at the time [`notify`](:func:`notify`) is
1111
called can be woken up. For level-triggered notifications, you must keep extra state to keep
1212
track of whether a notification has happened. The [`Channel`](:class:`Channel`) type does
1313
this, and so can be used for level-triggered events.
@@ -60,7 +60,7 @@ n_waiters(c::Condition) = length(c.waitq)
6060
"""
6161
@schedule
6262
63-
Wrap an expression in a `Task` and add it to the local machine's scheduler queue.
63+
Wrap an expression in a [`Task`](:obj:`Task`) and add it to the local machine's scheduler queue.
6464
"""
6565
macro schedule(expr)
6666
expr = :(()->($expr))
@@ -84,11 +84,11 @@ schedule(t::Task) = enq_work(t)
8484
"""
8585
schedule(t::Task, [val]; error=false)
8686
87-
Add a task to the scheduler's queue. This causes the task to run constantly when the system
88-
is otherwise idle, unless the task performs a blocking operation such as `wait`.
87+
Add a [`Task`](:obj:`Task`) to the scheduler's queue. This causes the task to run constantly when the system
88+
is otherwise idle, unless the task performs a blocking operation such as [`wait`](:func:`wait`).
8989
9090
If a second argument `val` is provided, it will be passed to the task (via the return value of
91-
`yieldto`) when it runs again. If `error` is `true`, the value is raised as an exception in
91+
[`yieldto`](:func:`yieldto`)) when it runs again. If `error` is `true`, the value is raised as an exception in
9292
the woken task.
9393
"""
9494
function schedule(t::Task, arg; error=false)
@@ -124,7 +124,7 @@ tasks.
124124
yield() = (enq_work(current_task()); wait())
125125

126126
"""
127-
yieldto(task, arg = nothing)
127+
yieldto(t::Task, arg = nothing)
128128
129129
Switch to the given task. The first time a task is switched to, the task's function is
130130
called with no arguments. On subsequent switches, `arg` is returned from the task's last
@@ -203,10 +203,11 @@ end
203203
"""
204204
AsyncCondition()
205205
206-
Create a async condition that wakes up tasks waiting for it (by calling `wait` on the object)
207-
when notified from C by a call to uv_async_send.
208-
Waiting tasks are woken with an error when the object is closed (by `close`).
209-
Use `isopen` to check whether it is still active.
206+
Create a async condition that wakes up tasks waiting for it
207+
(by calling [`wait`](:func:`wait`) on the object)
208+
when notified from C by a call to `uv_async_send`.
209+
Waiting tasks are woken with an error when the object is closed (by [`close`](:func:`close`).
210+
Use [`isopen`](:func:`isopen`) to check whether it is still active.
210211
"""
211212
type AsyncCondition
212213
handle::Ptr{Void}
@@ -277,9 +278,9 @@ end
277278
"""
278279
Timer(delay, repeat=0)
279280
280-
Create a timer that wakes up tasks waiting for it (by calling `wait` on the timer object) at
281+
Create a timer that wakes up tasks waiting for it (by calling [`wait`](:func:`wait`) on the timer object) at
281282
a specified interval. Times are in seconds. Waiting tasks are woken with an error when the
282-
timer is closed (by `close`). Use `isopen` to check whether a timer is still active.
283+
timer is closed (by [`close`](:func:`close`). Use [`isopen`](:func:`isopen`) to check whether a timer is still active.
283284
"""
284285
type Timer
285286
handle::Ptr{Void}
@@ -367,7 +368,7 @@ Create a timer to call the given `callback` function. The `callback` is passed o
367368
the timer object itself. The callback will be invoked after the specified initial `delay`,
368369
and then repeating with the given `repeat` interval. If `repeat` is `0`, the timer is only
369370
triggered once. Times are in seconds. A timer is stopped and has its resources freed by
370-
calling `close` on it.
371+
calling [`close`](:func:`close`) on it.
371372
"""
372373
function Timer(cb::Function, timeout::Real, repeat::Real=0.0)
373374
t = Timer(timeout, repeat)

base/managers.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ end
346346
Implemented by cluster managers. For every Julia worker launched by this function, it should
347347
append a `WorkerConfig` entry to `launched` and notify `launch_ntfy`. The function MUST exit
348348
once all workers, requested by `manager` have been launched. `params` is a dictionary of all
349-
keyword arguments `addprocs` was called with.
349+
keyword arguments [`addprocs`](:func:`addprocs`) was called with.
350350
"""
351351
launch
352352

@@ -510,9 +510,11 @@ end
510510
"""
511511
kill(manager::ClusterManager, pid::Int, config::WorkerConfig)
512512
513-
Implemented by cluster managers. It is called on the master process, by `rmprocs`. It should
514-
cause the remote worker specified by `pid` to exit. `Base.kill(manager::ClusterManager.....)`
515-
executes a remote `exit()` on `pid`
513+
Implemented by cluster managers.
514+
It is called on the master process, by [`rmprocs`](:func:`rmprocs`).
515+
It should cause the remote worker specified by `pid` to exit.
516+
`Base.kill(manager::ClusterManager.....)` executes a remote `exit()`
517+
on `pid`.
516518
"""
517519
function kill(manager::ClusterManager, pid::Int, config::WorkerConfig)
518520
remote_do(exit, pid) # For TCP based transports this will result in a close of the socket

0 commit comments

Comments
 (0)