[Groonga-commit] groonga/groonga at 05087af [master] mrb: add Groonga::Thread.limit=

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Nov 14 15:52:05 JST 2017


Kouhei Sutou	2017-11-14 15:52:05 +0900 (Tue, 14 Nov 2017)

  New Revision: 05087aff92a31376d2769856817b2d1cfdbdbfb7
  https://github.com/groonga/groonga/commit/05087aff92a31376d2769856817b2d1cfdbdbfb7

  Message:
    mrb: add Groonga::Thread.limit=

  Modified files:
    lib/mrb/mrb_thread.c

  Modified: lib/mrb/mrb_thread.c (+19 -2)
===================================================================
--- lib/mrb/mrb_thread.c    2017-11-13 21:52:15 +0900 (6085543e1)
+++ lib/mrb/mrb_thread.c    2017-11-14 15:52:05 +0900 (3edab5c37)
@@ -24,13 +24,28 @@
 #include "mrb_thread.h"
 
 static mrb_value
-thread_limit(mrb_state *mrb, mrb_value self)
+thread_get_limit(mrb_state *mrb, mrb_value self)
 {
   uint32_t limit;
   limit = grn_thread_get_limit();
   return mrb_fixnum_value(limit);
 }
 
+static mrb_value
+thread_set_limit(mrb_state *mrb, mrb_value self)
+{
+  mrb_int limit;
+
+  mrb_get_args(mrb, "i", &limit);
+  if (limit < 1) {
+    mrb_raisef(mrb, E_ARGUMENT_ERROR,
+               "thread limit must be 1 or larger: %S",
+               mrb_fixnum_value(limit));
+  }
+  grn_thread_set_limit(limit);
+  return mrb_nil_value();
+}
+
 void
 grn_mrb_thread_init(grn_ctx *ctx)
 {
@@ -41,6 +56,8 @@ grn_mrb_thread_init(grn_ctx *ctx)
   thread_module = mrb_define_module_under(mrb, module, "Thread");
 
   mrb_define_class_method(mrb, thread_module,
-                          "limit", thread_limit, MRB_ARGS_NONE());
+                          "limit", thread_get_limit, MRB_ARGS_NONE());
+  mrb_define_class_method(mrb, thread_module,
+                          "limit=", thread_set_limit, MRB_ARGS_REQ(1));
 }
 #endif
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20171114/65642926/attachment.htm 



More information about the Groonga-commit mailing list
Back to archive index