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.

135 lines
5.9 KiB

  1. /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
  2. // vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
  3. #ident "$Id$"
  4. /*
  5. COPYING CONDITIONS NOTICE:
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of version 2 of the GNU General Public License as
  8. published by the Free Software Foundation, and provided that the
  9. following conditions are met:
  10. * Redistributions of source code must retain this COPYING
  11. CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
  12. DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
  13. PATENT MARKING NOTICE (below), and the PATENT RIGHTS
  14. GRANT (below).
  15. * Redistributions in binary form must reproduce this COPYING
  16. CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
  17. DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
  18. PATENT MARKING NOTICE (below), and the PATENT RIGHTS
  19. GRANT (below) in the documentation and/or other materials
  20. provided with the distribution.
  21. You should have received a copy of the GNU General Public License
  22. along with this program; if not, write to the Free Software
  23. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  24. 02110-1301, USA.
  25. COPYRIGHT NOTICE:
  26. TokuDB, Tokutek Fractal Tree Indexing Library.
  27. Copyright (C) 2007-2013 Tokutek, Inc.
  28. DISCLAIMER:
  29. This program is distributed in the hope that it will be useful, but
  30. WITHOUT ANY WARRANTY; without even the implied warranty of
  31. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  32. General Public License for more details.
  33. UNIVERSITY PATENT NOTICE:
  34. The technology is licensed by the Massachusetts Institute of
  35. Technology, Rutgers State University of New Jersey, and the Research
  36. Foundation of State University of New York at Stony Brook under
  37. United States of America Serial No. 11/760379 and to the patents
  38. and/or patent applications resulting from it.
  39. PATENT MARKING NOTICE:
  40. This software is covered by US Patent No. 8,185,551.
  41. PATENT RIGHTS GRANT:
  42. "THIS IMPLEMENTATION" means the copyrightable works distributed by
  43. Tokutek as part of the Fractal Tree project.
  44. "PATENT CLAIMS" means the claims of patents that are owned or
  45. licensable by Tokutek, both currently or in the future; and that in
  46. the absence of this license would be infringed by THIS
  47. IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
  48. "PATENT CHALLENGE" shall mean a challenge to the validity,
  49. patentability, enforceability and/or non-infringement of any of the
  50. PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
  51. Tokutek hereby grants to you, for the term and geographical scope of
  52. the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
  53. irrevocable (except as stated in this section) patent license to
  54. make, have made, use, offer to sell, sell, import, transfer, and
  55. otherwise run, modify, and propagate the contents of THIS
  56. IMPLEMENTATION, where such license applies only to the PATENT
  57. CLAIMS. This grant does not include claims that would be infringed
  58. only as a consequence of further modifications of THIS
  59. IMPLEMENTATION. If you or your agent or licensee institute or order
  60. or agree to the institution of patent litigation against any entity
  61. (including a cross-claim or counterclaim in a lawsuit) alleging that
  62. THIS IMPLEMENTATION constitutes direct or contributory patent
  63. infringement, or inducement of patent infringement, then any rights
  64. granted to you under this License shall terminate as of the date
  65. such litigation is filed. If you or your agent or exclusive
  66. licensee institute or order or agree to the institution of a PATENT
  67. CHALLENGE, then Tokutek may terminate any rights granted to you
  68. under this License.
  69. */
  70. #ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
  71. #ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
  72. // A threadpool is a limited set of threads that can be used to apply a
  73. // function to work contained in a work queue. The work queue is outside
  74. // of the scope of the threadpool; the threadpool merely provides
  75. // mechanisms to grow the number of threads in the threadpool on demand.
  76. typedef struct threadpool *THREADPOOL;
  77. // Create a new threadpool
  78. // Effects: a new threadpool is allocated and initialized. the number of
  79. // threads in the threadpool is limited to max_threads. initially, there
  80. // are no threads in the pool.
  81. // Returns: if there are no errors, the threadpool is set and zero is returned.
  82. // Otherwise, an error number is returned.
  83. int threadpool_create(THREADPOOL *threadpoolptr, int max_threads);
  84. // Destroy a threadpool
  85. // Effects: the calling thread joins with all of the threads in the threadpool.
  86. // Effects: the threadpool memory is freed.
  87. // Returns: the threadpool is set to null.
  88. void threadpool_destroy(THREADPOOL *threadpoolptr);
  89. // Maybe add a thread to the threadpool.
  90. // Effects: the number of threads in the threadpool is expanded by 1 as long
  91. // as the current number of threads in the threadpool is less than the max
  92. // and there are no idle threads.
  93. // Effects: if the thread is create, it calls the function f with argument arg
  94. // Expects: external serialization on this function; only one thread may
  95. // execute this function
  96. void threadpool_maybe_add(THREADPOOL theadpool, void *(*f)(void *), void *arg);
  97. // Set the current thread busy
  98. // Effects: the threadpool keeps a count of the number of idle threads. It
  99. // uses this count to control the creation of additional threads.
  100. void threadpool_set_thread_busy(THREADPOOL);
  101. // Set the current thread idle
  102. void threadpool_set_thread_idle(THREADPOOL);
  103. // get the current number of threads
  104. int threadpool_get_current_threads(THREADPOOL);