@@ -95,6 +95,8 @@ $ python3 -m micropip.py install -p ~/syn micropython-uasyncio
95
95
96
96
3.6 [ Task cancellation] ( ./TUTORIAL.md#36-task-cancellation )
97
97
98
+ 3.7 [ Other synchronisation primitives] ( ./TUTORIAL.md#37-other-synchronisation-primitives )
99
+
98
100
4 . [ Designing classes for asyncio] ( ./TUTORIAL.md#4-designing-classes-for-asyncio )
99
101
100
102
4.1 [ Awaitable classes] ( ./TUTORIAL.md#41-awaitable-classes )
@@ -393,7 +395,7 @@ may be found [here](./PRIMITIVES.md).
393
395
394
396
## 3.1 Lock
395
397
396
- This describes the use of the official ` Lock ` primitive. [ Full details. ] ( ./PRIMITIVES.md#32-class-lock )
398
+ This describes the use of the official ` Lock ` primitive.
397
399
398
400
This guarantees unique access to a shared resource. In the following code
399
401
sample a ` Lock ` instance ` lock ` has been created and is passed to all coros
@@ -433,9 +435,10 @@ and the timeout is triggered while it is waiting on a lock, the timeout will be
433
435
ineffective. It will not receive the ` TimeoutError ` until it has acquired the
434
436
lock. The same observation applies to task cancellation.
435
437
436
- The module ` asyn.py ` offers a ` Lock ` class which works in these situations. It
437
- is significantly less efficient than the official class but supports additional
438
- interfaces as per the CPython version including context manager usage.
438
+ The module ` asyn.py ` offers a ` Lock ` class which works in these situations
439
+ [ Full details.] ( ./PRIMITIVES.md#32-class-lock ) . It is significantly less
440
+ efficient than the official class but supports additional interfaces as per the
441
+ CPython version including context manager usage.
439
442
440
443
###### [ Contents] ( ./TUTORIAL.md#contents )
441
444
@@ -658,6 +661,22 @@ async def foo():
658
661
659
662
###### [ Contents] ( ./TUTORIAL.md#contents )
660
663
664
+ ## 3.7 Other synchronisation primitives
665
+
666
+ The ` asyn.py ` library provides 'micro' implementations of CPython capabilities,
667
+ namely the [ Condition class] ( ./PRIMITIVES.md#36-class-condition ) and the
668
+ [ gather] ( ./PRIMITIVES.md#37-class-gather ) method.
669
+
670
+ The ` Condition ` class enables a coro to notify other coros which are waiting on
671
+ a locked resource. Once notified they will access the resource and release the
672
+ lock in turn. The notifying coro can limit the number of coros to be notified.
673
+
674
+ The CPython ` gather ` method enables a list of coros to be launched. When the
675
+ last has completed a list of results is returned. This 'micro' implementation
676
+ uses different syntax. Timeouts may be applied to any of the coros.
677
+
678
+ ###### [ Contents] ( ./TUTORIAL.md#contents )
679
+
661
680
# 4 Designing classes for asyncio
662
681
663
682
In the context of device drivers the aim is to ensure nonblocking operation.
0 commit comments