bio
 
Loading...
Searching...
No Matches
Monitor

Monitor a coroutine for termination. More...

Functions

bio_monitor_t bio_monitor (bio_coro_t coro, bio_signal_t signal)
 Monitor a coroutine for termination.
 
void bio_unmonitor (bio_monitor_t monitor)
 Discard a monitor.
 
static void bio_join (bio_coro_t coro)
 Convenient function to wait for a coroutine to terminate.
 

Detailed Description

Monitor a coroutine for termination.

Function Documentation

◆ bio_join()

static void bio_join ( bio_coro_t  coro)
inlinestatic

Convenient function to wait for a coroutine to terminate.

This makes use of bio_monitor to wait for the targeted coroutine.

See also
bio_monitor

◆ bio_monitor()

bio_monitor_t bio_monitor ( bio_coro_t  coro,
bio_signal_t  signal 
)

Monitor a coroutine for termination.

The provided signal would be raised when the given coro terminates.

A coroutine can be monitored several times and each would result in separate signal delivery.

It is valid to pass the same signal to different calls to to bio_monitor since raising an already raised signal is safe. This would allow the monitoring coroutine to wait for at least one of the monitored coroutine to terminate.

Dynamic memory is allocated to track the state of a monitor. When a monitoring coroutine is no longer interested in the monitored coroutine, the monitor should be discarded with bio_unmonitor. Otherwise, it will continue to take up memory. However, when a coroutine terminates, all monitors attached to it will be automatically freed.

Parameters
coroThe coroutine to monitor
signalThe signal that would be raised when the coroutine terminates
Returns
A handle for this monitor
See also
bio_make_signal
bio_unmonitor

◆ bio_unmonitor()

void bio_unmonitor ( bio_monitor_t  monitor)

Discard a monitor.

If the monitored coroutine has already terminated, the associated signal might already be raised.

As with all resources in bio, calling this multiple times on the same monitor is safe.

See also
bio_monitor