1 | /* -*- c-basic-offset: 2 -*- */ |
2 | /* |
3 | Copyright(C) 2015 Brazil |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License version 2.1 as published by the Free Software Foundation. |
8 | |
9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Lesser General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU Lesser General Public |
15 | License along with this library; if not, write to the Free Software |
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
17 | */ |
18 | |
19 | #include "grn_ctx.h" |
20 | |
21 | static grn_thread_get_limit_func get_limit_func = NULL; |
22 | static void *get_limit_func_data = NULL; |
23 | static grn_thread_set_limit_func set_limit_func = NULL; |
24 | static void *set_limit_func_data = NULL; |
25 | |
26 | uint32_t |
27 | grn_thread_get_limit(void) |
28 | { |
29 | if (get_limit_func) { |
30 | return get_limit_func(get_limit_func_data); |
31 | } else { |
32 | return 0; |
33 | } |
34 | } |
35 | |
36 | void |
37 | grn_thread_set_limit(uint32_t new_limit) |
38 | { |
39 | if (!set_limit_func) { |
40 | return; |
41 | } |
42 | |
43 | set_limit_func(new_limit, set_limit_func_data); |
44 | } |
45 | |
46 | void |
47 | grn_thread_set_get_limit_func(grn_thread_get_limit_func func, |
48 | void *data) |
49 | { |
50 | get_limit_func = func; |
51 | get_limit_func_data = data; |
52 | } |
53 | |
54 | void |
55 | grn_thread_set_set_limit_func(grn_thread_set_limit_func func, void *data) |
56 | { |
57 | set_limit_func = func; |
58 | set_limit_func_data = data; |
59 | } |
60 | |