Skip to content

Commit c07f7b6

Browse files
committed
PRIMITIVES.md add TOC.
1 parent 64a5f8f commit c07f7b6

File tree

2 files changed

+109
-45
lines changed

2 files changed

+109
-45
lines changed

PRIMITIVES.md

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,50 @@ task monitoring and cancellation.
55

66
###### [Main README](./README.md)
77

8+
# Contents
9+
10+
1. [The asyn.py library](./PRIMITIVES.md#1-the-asyn.py-library)
11+
12+
1.1 [Synchronisation Primitives](./PRIMITIVES.md#11-synchronisation-primitives)
13+
14+
1.2 [Task control and monitoring](./PRIMITIVES.md#12-task-control-and-monitoring)
15+
16+
2. [Modules](./PRIMITIVES.md#2-modules)
17+
18+
3 [Synchronisation Primitives](./PRIMITIVES.md#3-synchronisation-primitives)
19+
20+
3.1 [Function launch](./PRIMITIVES.md#31-function-launch)
21+
22+
3.2 [Class Lock](./PRIMITIVES.md#32-class-lock)
23+
24+
3.2.1 [Definition](./PRIMITIVES.md#321-definition)
25+
26+
3.3 [Class Event](./PRIMITIVES.md#33-class-event)
27+
28+
3.3.1 [Definition](./PRIMITIVES.md#331-definition)
29+
30+
3.4 [Class Barrier](./PRIMITIVES.md#34-class-barrier)
31+
32+
3.5 [Class Semaphore](./PRIMITIVES.md#35-class-semaphore)
33+
34+
3.5.1 [Class BoundedSemaphore](./PRIMITIVES.md#351-class-boundedsemaphore)
35+
36+
4. [Task Cancellation](./PRIMITIVES.md#4-task-cancellation)
37+
38+
4.1 [Coro sleep](./PRIMITIVES.md#41-coro-sleep)
39+
40+
4.2 [Class Cancellable](./PRIMITIVES.md#42-class-cancellable)
41+
42+
4.2.1 [Groups](./PRIMITIVES.md#421-groups)
43+
44+
4.2.2 [Custom cleanup](./PRIMITIVES.md#422-custom-cleanup)
45+
46+
4.3 [Class NamedTask](./PRIMITIVES.md#43-class-namedtask)
47+
48+
4.3.1 [Latency and Barrier objects](./PRIMITIVES.md#431-latency-and-barrier-objects)
49+
50+
4.3.2 [Custom cleanup](./PRIMITIVES.md#432-custom-cleanup)
51+
852
## 1.1 Synchronisation Primitives
953

1054
There is often a need to provide synchronisation between coros. A common
@@ -25,17 +69,15 @@ arrival (with other coros getting scheduled for the duration). The `Queue`
2569
guarantees that items are removed in the order in which they were received. As
2670
this is a part of the uasyncio library its use is described in the [tutorial](./TUTORIAL.md).
2771

72+
###### [Contents](./PRIMITIVES.md#contents)
73+
2874
## 1.2 Task control and monitoring
2975

3076
`uasyncio` does not implement the `Task` and `Future` classes of `asyncio`.
3177
Instead it uses a 'micro' lightweight means of task cancellation. The `asyn.py`
3278
module provides an API to simplify its use and to check on the running status
3379
of coroutines which are subject to cancellation.
3480

35-
**NOTE** The task cancellation API has changed. Hopefully it is now stable.
36-
37-
###### [Main README](./README.md)
38-
3981
# 2. Modules
4082

4183
The following modules are provided:
@@ -46,6 +88,8 @@ The following modules are provided:
4688

4789
Import the test or demo module for a list of available tests.
4890

91+
###### [Contents](./PRIMITIVES.md#contents)
92+
4993
# 3. Synchronisation Primitives
5094

5195
The primitives are intended for use only with `uasyncio`. They are `micro` in
@@ -107,6 +151,8 @@ Methods:
107151
* `acquire` No args. Coro which pauses until the lock has been acquired. Use
108152
by executing `await lock.acquire()`.
109153

154+
###### [Contents](./PRIMITIVES.md#contents)
155+
110156
## 3.3 Class Event
111157

112158
This provides a way for one or more coros to pause until another one flags them
@@ -167,6 +213,8 @@ Synchronous Methods:
167213
The optional data value may be used to compensate for the latency in awaiting
168214
the event by passing `loop.time()`.
169215

216+
###### [Contents](./PRIMITIVES.md#contents)
217+
170218
## 3.4 Class Barrier
171219

172220
This enables multiple coros to rendezvous at a particular point. For example
@@ -222,6 +270,8 @@ async def foo(n):
222270
Note that `await barrier(nowait = True)` should not be issued in a looping
223271
construct.
224272

273+
###### [Contents](./PRIMITIVES.md#contents)
274+
225275
## 3.5 Class Semaphore
226276

227277
A semaphore limits the number of coros which can access a resource. It can be
@@ -258,8 +308,13 @@ This works identically to the `Semaphore` class except that if the `release`
258308
method causes the access counter to exceed its initial value, a `ValueError`
259309
is raised.
260310

311+
###### [Contents](./PRIMITIVES.md#contents)
312+
261313
# 4. Task Cancellation
262314

315+
Note to users of releases prior to 31st Dec 2017: this API has changed. It
316+
should now be stable.
317+
263318
In `uasyncio` task cancellation is achieved by throwing an exception to the
264319
coro to be cancelled. Cancellation occurs when it is next scheduled. If a coro
265320
issues `await uasyncio.sleep(secs)` or `uasyncio.sleep_ms(ms)` scheduling will
@@ -407,6 +462,8 @@ async def bar(task_id):
407462
Cancellable.end(task_no)
408463
```
409464

465+
###### [Contents](./PRIMITIVES.md#contents)
466+
410467
## 4.3 Class NamedTask
411468

412469
A `NamedTask` instance is associated with a user-defined name such that the
@@ -509,6 +566,8 @@ async def foo(_):
509566
return False
510567
```
511568

569+
###### [Contents](./PRIMITIVES.md#contents)
570+
512571
#### ExitGate (obsolete)
513572

514573
This was a nasty hack to fake task cancellation at a time when uasyncio did not

0 commit comments

Comments
 (0)