Commit cdf9c864 authored by Jim Mussared's avatar Jim Mussared

docs/library/uasyncio.rst: Add docs for ThreadSafeFlag.

Signed-off-by: default avatarJim Mussared <jim.mussared@gmail.com>
parent 5e96e899
......@@ -125,6 +125,9 @@ class Event
Set the event. Any tasks waiting on the event will be scheduled to run.
Note: This must be called from within a task. It is not safe to call this
from an IRQ, scheduler callback, or other thread. See `ThreadSafeFlag`.
.. method:: Event.clear()
Clear the event.
......@@ -136,6 +139,29 @@ class Event
This is a coroutine.
class ThreadSafeFlag
--------------------
.. class:: ThreadSafeFlag()
Create a new flag which can be used to synchronise a task with code running
outside the asyncio loop, such as other threads, IRQs, or scheduler
callbacks. Flags start in the cleared state.
.. method:: ThreadSafeFlag.set()
Set the flag. If there is a task waiting on the event, it will be scheduled
to run.
.. method:: ThreadSafeFlag.wait()
Wait for the flag to be set. If the flag is already set then it returns
immediately.
A flag may only be waited on by a single task at a time.
This is a coroutine.
class Lock
----------
......@@ -188,7 +214,7 @@ TCP stream connections
This is a coroutine.
.. class:: Stream()
This represents a TCP stream connection. To minimise code this class implements
both a reader and a writer, and both ``StreamReader`` and ``StreamWriter`` alias to
this class.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment