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.

85 lines
2.6 KiB

  1. /*****************************************************************************
  2. Copyright (c) 2006, 2009, Innobase Oy. All Rights Reserved.
  3. This program is free software; you can redistribute it and/or modify it under
  4. the terms of the GNU General Public License as published by the Free Software
  5. Foundation; version 2 of the License.
  6. This program is distributed in the hope that it will be useful, but WITHOUT
  7. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along with
  10. this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  11. Place, Suite 330, Boston, MA 02111-1307 USA
  12. *****************************************************************************/
  13. /*******************************************************************//**
  14. @file include/ut0wqueue.h
  15. A work queue
  16. Created 4/26/2006 Osku Salerma
  17. ************************************************************************/
  18. /*******************************************************************//**
  19. A Work queue. Threads can add work items to the queue and other threads can
  20. wait for work items to be available and take them off the queue for
  21. processing.
  22. ************************************************************************/
  23. #ifndef IB_WORK_QUEUE_H
  24. #define IB_WORK_QUEUE_H
  25. #include "ut0list.h"
  26. #include "mem0mem.h"
  27. #include "os0sync.h"
  28. #include "sync0types.h"
  29. typedef struct ib_wqueue_struct ib_wqueue_t;
  30. /****************************************************************//**
  31. Create a new work queue.
  32. @return work queue */
  33. UNIV_INTERN
  34. ib_wqueue_t*
  35. ib_wqueue_create(void);
  36. /*===================*/
  37. /****************************************************************//**
  38. Free a work queue. */
  39. UNIV_INTERN
  40. void
  41. ib_wqueue_free(
  42. /*===========*/
  43. ib_wqueue_t* wq); /*!< in: work queue */
  44. /****************************************************************//**
  45. Add a work item to the queue. */
  46. UNIV_INTERN
  47. void
  48. ib_wqueue_add(
  49. /*==========*/
  50. ib_wqueue_t* wq, /*!< in: work queue */
  51. void* item, /*!< in: work item */
  52. mem_heap_t* heap); /*!< in: memory heap to use for allocating the
  53. list node */
  54. /****************************************************************//**
  55. Wait for a work item to appear in the queue.
  56. @return work item */
  57. UNIV_INTERN
  58. void*
  59. ib_wqueue_wait(
  60. /*===========*/
  61. ib_wqueue_t* wq); /*!< in: work queue */
  62. /* Work queue. */
  63. struct ib_wqueue_struct {
  64. mutex_t mutex; /*!< mutex protecting everything */
  65. ib_list_t* items; /*!< work item list */
  66. os_event_t event; /*!< event we use to signal additions to list */
  67. };
  68. #endif