You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

aio_event.h 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*-
  2. * Copyright 2016 Vsevolod Stakhov
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef AIO_EVENT_H_
  17. #define AIO_EVENT_H_
  18. #include "config.h"
  19. /**
  20. * AIO context
  21. */
  22. struct aio_context;
  23. /**
  24. * Callback for notifying
  25. */
  26. typedef void (*rspamd_aio_cb) (gint fd, gint res, guint64 len, gpointer data,
  27. gpointer ud);
  28. /**
  29. * Initialize aio with specified event base
  30. */
  31. struct aio_context * rspamd_aio_init (struct event_base *base);
  32. /**
  33. * Open file for aio
  34. */
  35. gint rspamd_aio_open (struct aio_context *ctx, const gchar *path, int flags);
  36. /**
  37. * Asynchronous read of file
  38. */
  39. gint rspamd_aio_read (gint fd, gpointer buf, guint64 len, guint64 offset,
  40. struct aio_context *ctx, rspamd_aio_cb cb, gpointer ud);
  41. /**
  42. * Asynchronous write of file
  43. */
  44. gint rspamd_aio_write (gint fd, gpointer buf, guint64 len, guint64 offset,
  45. struct aio_context *ctx, rspamd_aio_cb cb, gpointer ud);
  46. /**
  47. * Close of aio operations
  48. */
  49. gint rspamd_aio_close (gint fd, struct aio_context *ctx);
  50. #endif /* AIO_EVENT_H_ */