msgr.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* This file is part of libepistle.
  2. *
  3. * libepistle is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU Lesser General Public License as published by
  5. * the Free Software Foundation, either version 3 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * libepistle is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU Lesser General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Lesser General Public License
  14. * along with libepistle. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef EPISTLE_MSGR_H
  17. #define EPISTLE_MSGR_H
  18. #include <primo/map.h>
  19. #include "message.h"
  20. typedef Map Msgrs;
  21. typedef struct {
  22. int fd;
  23. List inbox;
  24. Msg *wip;
  25. void *extra;
  26. } Msgr;
  27. int
  28. msgrs_init(Msgrs *msgrs, Disposer *dspr, Err *err);
  29. void
  30. msgrs_dispose(Msgrs *msgrs);
  31. Msgr *
  32. msgr_add(Msgrs *msgrs, uint32_t key_len, const void *key,
  33. int fd, int epoll_fd, void *extra, Err *err);
  34. int
  35. msgr_remove(Msgrs *msgrs, uint32_t key_len, const void *key,
  36. void **extra, Err *err);
  37. Msgr *
  38. msgr_get(Msgrs *msgrs, uint32_t key_len, const void *key);
  39. int
  40. msgr_recv(Msgr *msgr, uint32_t max_len, int wait, Err *err);
  41. int
  42. msgr_post(Msgr *msgr, Msg *msg, Err *err);
  43. int
  44. msgr_send(Msgr *msgr, int epoll_fd, int wait, Err *err);
  45. #endif