extmod/uasyncio: Add clear method to ThreadSafeFlag.
This is useful in situations where the ThreadSafeFlag is reused and needs to be cleared of any previous, unwanted event. For example, clear the flag at the start of an operation, trigger the operation (eg an I2C write), then (a)wait for an external event to set the flag (eg a pin IRQ). Further events may trigger the flag again but these are unwanted and should be cleared before the next cycle starts.
This commit is contained in:
@@ -153,9 +153,14 @@ class ThreadSafeFlag
|
||||
|
||||
.. method:: ThreadSafeFlag.set()
|
||||
|
||||
Set the flag. If there is a task waiting on the event, it will be scheduled
|
||||
Set the flag. If there is a task waiting on the flag, it will be scheduled
|
||||
to run.
|
||||
|
||||
.. method:: ThreadSafeFlag.clear()
|
||||
|
||||
Clear the flag. This may be used to ensure that a possibly previously-set
|
||||
flag is clear before waiting for it.
|
||||
|
||||
.. method:: ThreadSafeFlag.wait()
|
||||
|
||||
Wait for the flag to be set. If the flag is already set then it returns
|
||||
|
||||
Reference in New Issue
Block a user