lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, Sep 20, 2022 at 10:21 PM Jorge Visca <xxopxe@gmail.com> wrote:
I wonder how would you handle waiting on several
signals?

First, it needs cancellation (coming in part 3).

Given that, I usually implement a `wait_any()` utility.  The inputs can be any function that uses return of control to signal the event.  (For example, the async_wait() method of Event.)  Then:

```
-- run these functions concurrently; when one returns, cancel the others
async_wait_any(
    event_foo.async_wait,
    async_wait_for_bar,
    async_do_baz,
    ...)
```