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 | This file is part of PerconaFT. |
6 | |
7 | |
8 | Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. |
9 | |
10 | PerconaFT is free software: you can redistribute it and/or modify |
11 | it under the terms of the GNU General Public License, version 2, |
12 | as published by the Free Software Foundation. |
13 | |
14 | PerconaFT is distributed in the hope that it will be useful, |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | GNU General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU General Public License |
20 | along with PerconaFT. If not, see <http://www.gnu.org/licenses/>. |
21 | |
22 | ---------------------------------------- |
23 | |
24 | PerconaFT is free software: you can redistribute it and/or modify |
25 | it under the terms of the GNU Affero General Public License, version 3, |
26 | as published by the Free Software Foundation. |
27 | |
28 | PerconaFT is distributed in the hope that it will be useful, |
29 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
30 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
31 | GNU Affero General Public License for more details. |
32 | |
33 | You should have received a copy of the GNU Affero General Public License |
34 | along with PerconaFT. If not, see <http://www.gnu.org/licenses/>. |
35 | ======= */ |
36 | |
37 | #ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." |
38 | |
39 | #pragma once |
40 | |
41 | // |
42 | // The kibbutz is another threadpool meant to do arbitrary work. |
43 | // |
44 | |
45 | typedef struct kibbutz *KIBBUTZ; |
46 | // |
47 | // create a kibbutz where n_workers is the number of threads in the threadpool |
48 | // |
49 | int toku_kibbutz_create (int n_workers, KIBBUTZ *kb); |
50 | // |
51 | // enqueue a workitem in the kibbutz. When the kibbutz is to work on this workitem, |
52 | // it calls f(extra). |
53 | // At any time, the kibbutz is operating on at most n_workers jobs. |
54 | // Other enqueued workitems are on a queue. An invariant is |
55 | // that no currently enqueued item was placed on the queue before |
56 | // any item that is currently being operated on. Another way to state |
57 | // this is that all items on the queue were placed there before any item |
58 | // that is currently being worked on |
59 | // |
60 | void toku_kibbutz_enq (KIBBUTZ k, void (*f)(void*), void *); |
61 | // |
62 | // get kibbuts status |
63 | // |
64 | void toku_kibbutz_get_status(KIBBUTZ k, |
65 | uint64_t *num_threads, |
66 | uint64_t *num_threads_active, |
67 | uint64_t *queue_size, |
68 | uint64_t *max_queue_size, |
69 | uint64_t *total_items_processed, |
70 | uint64_t *total_execution_time); |
71 | // |
72 | // destroys the kibbutz |
73 | // |
74 | void toku_kibbutz_destroy (KIBBUTZ k); |
75 | |