1 | /* -*- c-basic-offset: 2 -*- */ |
2 | /* |
3 | Copyright(C) 2016 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_impl.h" |
20 | |
21 | #ifdef GRN_WITH_MRUBY |
22 | #include <mruby.h> |
23 | |
24 | #include "mrb_thread.h" |
25 | |
26 | static mrb_value |
27 | thread_limit(mrb_state *mrb, mrb_value self) |
28 | { |
29 | uint32_t limit; |
30 | limit = grn_thread_get_limit(); |
31 | return mrb_fixnum_value(limit); |
32 | } |
33 | |
34 | void |
35 | grn_mrb_thread_init(grn_ctx *ctx) |
36 | { |
37 | mrb_state *mrb = ctx->impl->mrb.state; |
38 | struct RClass *module = ctx->impl->mrb.module; |
39 | struct RClass *thread_module; |
40 | |
41 | thread_module = mrb_define_module_under(mrb, module, "Thread" ); |
42 | |
43 | mrb_define_class_method(mrb, thread_module, |
44 | "limit" , thread_limit, MRB_ARGS_NONE()); |
45 | } |
46 | #endif |
47 | |