Kouhei Sutou
null+****@clear*****
Mon Aug 29 15:57:31 JST 2016
Kouhei Sutou 2016-08-29 15:57:31 +0900 (Mon, 29 Aug 2016) New Revision: a3069d6437f68f27c71a5841c89a255b214640d6 https://github.com/groonga/groonga/commit/a3069d6437f68f27c71a5841c89a255b214640d6 Message: mrb: add Thread.limit Added files: lib/mrb/mrb_thread.c lib/mrb/mrb_thread.h Modified files: lib/ctx_impl_mrb.c lib/mrb/sources.am Modified: lib/ctx_impl_mrb.c (+2 -0) =================================================================== --- lib/ctx_impl_mrb.c 2016-08-29 15:47:22 +0900 (cfb6c6f) +++ lib/ctx_impl_mrb.c 2016-08-29 15:57:31 +0900 (c8929fd) @@ -67,6 +67,7 @@ # include "mrb/mrb_writer.h" # include "mrb/mrb_config.h" # include "mrb/mrb_eval_context.h" +# include "mrb/mrb_thread.h" # include <mruby/array.h> # include <mruby/string.h> @@ -181,6 +182,7 @@ mrb_groonga_init(mrb_state *mrb, mrb_value self) grn_mrb_writer_init(ctx); grn_mrb_config_init(ctx); grn_mrb_eval_context_init(ctx); + grn_mrb_thread_init(ctx); grn_mrb_load(ctx, "initialize/post.rb"); Added: lib/mrb/mrb_thread.c (+46 -0) 100644 =================================================================== --- /dev/null +++ lib/mrb/mrb_thread.c 2016-08-29 15:57:31 +0900 (6085543) @@ -0,0 +1,46 @@ +/* -*- c-basic-offset: 2 -*- */ +/* + Copyright(C) 2016 Brazil + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License version 2.1 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "../grn_ctx_impl.h" + +#ifdef GRN_WITH_MRUBY +#include <mruby.h> + +#include "mrb_thread.h" + +static mrb_value +thread_limit(mrb_state *mrb, mrb_value self) +{ + uint32_t limit; + limit = grn_thread_get_limit(); + return mrb_fixnum_value(limit); +} + +void +grn_mrb_thread_init(grn_ctx *ctx) +{ + mrb_state *mrb = ctx->impl->mrb.state; + struct RClass *module = ctx->impl->mrb.module; + struct RClass *thread_module; + + thread_module = mrb_define_module_under(mrb, module, "Thread"); + + mrb_define_class_method(mrb, thread_module, + "limit", thread_limit, MRB_ARGS_NONE()); +} +#endif Added: lib/mrb/mrb_thread.h (+32 -0) 100644 =================================================================== --- /dev/null +++ lib/mrb/mrb_thread.h 2016-08-29 15:57:31 +0900 (946dd69) @@ -0,0 +1,32 @@ +/* -*- c-basic-offset: 2 -*- */ +/* + Copyright(C) 2016 Brazil + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License version 2.1 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once + +#include "../grn_ctx.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void grn_mrb_thread_init(grn_ctx *ctx); + +#ifdef __cplusplus +} +#endif + Modified: lib/mrb/sources.am (+2 -0) =================================================================== --- lib/mrb/sources.am 2016-08-29 15:47:22 +0900 (b30e834) +++ lib/mrb/sources.am 2016-08-29 15:57:31 +0900 (4130618) @@ -79,6 +79,8 @@ libgrnmrb_la_SOURCES = \ mrb_table_sort_flags.h \ mrb_table_sort_key.c \ mrb_table_sort_key.h \ + mrb_thread.c \ + mrb_thread.h \ mrb_type.c \ mrb_type.h \ mrb_variable_size_column.c \ -------------- next part -------------- HTML����������������������������... 下載