Skip to content

Commit 519d1df

Browse files
committed
Tutorial: add note re ThreadSafeFlag.
1 parent 05579e5 commit 519d1df

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

v3/docs/TUTORIAL.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,12 @@ Asynchronous method:
909909
* `wait` Wait for the flag to be set. If the flag is already set then it
910910
returns immediately.
911911

912-
Usage example: triggering from a hard ISR.
912+
Typical usage is having a `uasyncio` task wait on a hard ISR. Only one task
913+
should wait on a `ThreadSafeFlag`. The hard ISR services the interrupting
914+
device, sets the `ThreadSafeFlag`, and quits. A single task waits on the flag.
915+
This design conforms with the self-clearing behaviour of the `ThreadSafeFlag`.
916+
Each interrupting device has its own `ThreadSafeFlag` instance and its own
917+
waiting task.
913918
```python
914919
import uasyncio as asyncio
915920
from pyb import Timer
@@ -967,8 +972,8 @@ possible level of performance as discussed in
967972

968973
Regardless of performance issues, a key use for `ThreadSafeFlag` is where a
969974
hardware device requires the use of an ISR for a μs level response. Having
970-
serviced the device, the ISR flags an asynchronous routine, say to process
971-
received data.
975+
serviced the device, the ISR flags an asynchronous routine, typically
976+
processing received data.
972977

973978
The fact that only one task may wait on a `ThreadSafeFlag` may be addressed by
974979
having the task that waits on the `ThreadSafeFlag` set an `Event`. Multiple

0 commit comments

Comments
 (0)