std1.0.0-beta-7 SafeC docs

std :: async::channel

Struct std::Oneshot

#include <std/async/channel.h> source

generic<T: Send> struct Oneshot {
    T value[1];
    int state;
    struct WakerSlot rx;
    struct Spinlock lk;
}

One value, sent once, received once.

Fields

§T value[1]source
§int statesource

ONESHOT_*

Methods

§static struct Oneshot<T> new()source · definition
§int send(T v)source · definition

Store the value and wake the receiver. 1 on success, 0 if a value was already sent or the channel was closed.

§void close()source · definition

No value will come: the receiver gets null.

§void drop()source · definition

Closes it, releases the receiver's waker, and drops a value nobody received. Nothing may use the channel (or a future from it) after.

§struct OneshotRecv<T> recv()source · definition

The receive future: Ready(some(v)), or Ready(null) once closed.

§?T try_recv()source · definition

The value if it has arrived (and takes it), else null.

§int is_closed() constsource · definition