async.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. #define FAUX_ASYNC_UNLIMITED 0
  9. typedef struct faux_async_s faux_async_t;
  10. // Callback function prototypes
  11. typedef bool_t (*faux_async_read_cb_fn)(faux_async_t *async,
  12. void *data, size_t len, void *user_data);
  13. typedef bool_t (*faux_async_stall_cb_fn)(faux_async_t *async,
  14. size_t len, void *user_data);
  15. C_DECL_BEGIN
  16. faux_async_t *faux_async_new(int fd);
  17. void faux_async_free(faux_async_t *async);
  18. int faux_async_fd(const faux_async_t *async);
  19. void faux_async_set_read_cb(faux_async_t *async,
  20. faux_async_read_cb_fn read_cb, void *user_data);
  21. bool_t faux_async_set_read_limits(faux_async_t *async, size_t min, size_t max);
  22. void faux_async_set_stall_cb(faux_async_t *async,
  23. faux_async_stall_cb_fn stall_cb, void *user_data);
  24. void faux_async_set_write_overflow(faux_async_t *async, size_t overflow);
  25. void faux_async_set_read_overflow(faux_async_t *async, size_t overflow);
  26. ssize_t faux_async_write(faux_async_t *async, void *data, size_t len);
  27. ssize_t faux_async_out(faux_async_t *async);
  28. ssize_t faux_async_in(faux_async_t *async);
  29. C_DECL_END
  30. #endif // _faux_async_h