xrp_threaded_queue.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (c) 2016 - 2018 Cadence Design Systems Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining
  5. * a copy of this software and associated documentation files (the
  6. * "Software"), to deal in the Software without restriction, including
  7. * without limitation the rights to use, copy, modify, merge, publish,
  8. * distribute, sublicense, and/or sell copies of the Software, and to
  9. * permit persons to whom the Software is furnished to do so, subject to
  10. * the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included
  13. * in all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  18. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  19. * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  20. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  21. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. */
  23. #ifndef _XRP_THREADED_QUEUE_IMPL_H
  24. #define _XRP_THREADED_QUEUE_IMPL_H
  25. #include "xrp_thread_impl.h"
  26. struct xrp_queue_item {
  27. struct xrp_queue_item *next;
  28. };
  29. struct xrp_request_queue {
  30. xrp_thread thread;
  31. xrp_cond request_queue_cond;
  32. struct {
  33. struct xrp_queue_item *head;
  34. struct xrp_queue_item *tail;
  35. } request_queue;
  36. int exit;
  37. int *sync_exit;
  38. void *context;
  39. void (*fn)(struct xrp_queue_item *rq, void *context);
  40. };
  41. struct xrp_event_impl {
  42. xrp_cond cond;
  43. };
  44. void xrp_queue_init(struct xrp_request_queue *queue, int priority,
  45. void *context,
  46. void (*fn)(struct xrp_queue_item *rq, void *context));
  47. void xrp_queue_destroy(struct xrp_request_queue *queue);
  48. void xrp_queue_push(struct xrp_request_queue *queue,
  49. struct xrp_queue_item *rq);
  50. struct xrp_event *xrp_event_create(void);
  51. void xrp_impl_broadcast_event(struct xrp_event *event, enum xrp_status status);
  52. void xrp_impl_release_event(struct xrp_event *event);
  53. #endif