#ifndef __USTREAM_H
#define __USTREAM_H
+#include <stdarg.h>
#include "uloop.h"
struct ustream;
struct ustream {
struct ustream_buf_list r, w;
struct uloop_timeout state_change;
+ struct ustream *next;
/*
- * notify_read:
+ * notify_read: (optional)
* called by the ustream core to notify that new data is available
* for reading.
* must not free the ustream from this callback
void (*set_read_blocked)(struct ustream *s);
/*
+ * poll: (optional)
+ * defined by the upstream implementation, called to request polling for
+ * available data.
+ * returns true if data was fetched.
+ */
+ bool (*poll)(struct ustream *s);
+
+ /*
* ustream user should set this if the input stream is expected
* to contain string data. the core will keep all data 0-terminated.
*/
uloop_timeout_set(&s->state_change, 0);
}
+static inline bool ustream_poll(struct ustream *s)
+{
+ if (!s->poll)
+ return false;
+
+ return s->poll(s);
+}
+
#endif