X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Finclude%2Futils%2Fchannel.h;h=49d37fdcfec6ec6d87df83697a382fa243b48575;hb=01cf7d5f4392df0933e56a54b1ff607d2dd2ed13;hp=3eb7dc1897feab7639ec289ceb408089216f932b;hpb=19ab20f21c0fa168de54621e72121cc225d1d235;p=sysdb.git diff --git a/src/include/utils/channel.h b/src/include/utils/channel.h index 3eb7dc1..49d37fd 100644 --- a/src/include/utils/channel.h +++ b/src/include/utils/channel.h @@ -30,6 +30,8 @@ #include "core/object.h" +#include + #ifdef __cplusplus extern "C" { #endif @@ -89,6 +91,35 @@ sdb_channel_write(sdb_channel_t *chan, const void *data); int sdb_channel_read(sdb_channel_t *chan, void *data); +/* + * sdb_channel_select: + * Wait for a channel to become "ready" for I/O. A channel is considered ready + * if it is possible to perform the corresponding I/O operation successfully + * *in some thread*. In case 'wantread' or 'read_data' is non-NULL, wait for + * data to be available in the channel for reading. In case 'wantwrite' or + * 'write_data' is non-NULL, wait for buffer space to be available for writing + * to the channel. If non-NULL, the value pointed to by the 'want...' + * arguments will be "true" iff the respective operation is ready. If the + * '..._data' arguments are non-NULL, the respective operation is executed + * atomically once the channel is ready for it. If 'timeout' is specified, the + * operation will time out with an error after the specified time has passed. + */ +int +sdb_channel_select(sdb_channel_t *chan, int *wantread, void *read_data, + int *wantwrite, void *write_data, const struct timespec *timeout); + +/* sdb_channel_shutdown: + * Initiate a shutdown of the channel. Any subsequent writes will fail. Read + * operations will still be possible until the channel buffer is empty and + * then fail as well. Failing operations set errno to EBADF. + * + * Returns: + * - 0 on success + * - a negative value else + */ +int +sdb_channel_shutdown(sdb_channel_t *chan); + #ifdef __cplusplus } /* extern "C" */ #endif