async.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /** @file async.h
  2. * @brief Public interface for ASYNChronous I/O class.
  3. */
  4. #ifndef _faux_async_h
  5. #define _faux_async_h
  6. #include <faux/faux.h>
  7. #include <faux/sched.h>
  8. typedef struct faux_async_s faux_async_t;
  9. /*
  10. typedef enum {
  11. FAUX_ELOOP_NULL = 0,
  12. FAUX_ELOOP_SIGNAL = 1,
  13. FAUX_ELOOP_SCHED = 2,
  14. FAUX_ELOOP_FD = 3
  15. } faux_eloop_type_e;
  16. */
  17. // Callback function prototypes
  18. typedef bool_t (*faux_async_read_cb_f)(faux_async_t *async,
  19. void *data, size_t len, void *user_data);
  20. typedef bool_t (*faux_async_stall_cb_f)(faux_async_t *async,
  21. size_t len, void *user_data);
  22. C_DECL_BEGIN
  23. faux_async_t *faux_async_new(int fd);
  24. void faux_async_free(faux_async_t *async);
  25. int faux_async_fd(const faux_async_t *async);
  26. void faux_async_set_read_cb(faux_async_t *async,
  27. faux_async_read_cb_f read_cb, void *user_data);
  28. bool_t faux_async_set_read_limits(faux_async_t *async, size_t min, size_t max);
  29. void faux_async_set_stall_cb(faux_async_t *async,
  30. faux_async_stall_cb_f stall_cb, void *user_data);
  31. void faux_async_set_overflow(faux_async_t *async, size_t overflow);
  32. ssize_t faux_async_write(faux_async_t *async, void *data, size_t len);
  33. ssize_t faux_async_out(faux_async_t *async);
  34. C_DECL_END
  35. #endif // _faux_async_h