Debian Codegraph @

lib/proc/proc_thread.c

raw symbols SCIP
1 /*
2 Copyright(C) 2009-2018 Brazil
3 Copyright(C) 2021 Sutou Kouhei <[email protected]>
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 as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #include "../grn_ctx.h"cxx . . $ `<file>/lib/grn_ctx.h`/
21 #include "../grn_output.h"cxx . . $ `<file>/lib/grn_output.h`/
22 #include "../grn_proc.h"cxx . . $ `<file>/lib/grn_proc.h`/
23 #include "../grn_logger.h"cxx . . $ `<file>/lib/grn_logger.h`/
24 #include "../grn_str.h"cxx . . $ `<file>/lib/grn_str.h`/
25
26 #include <groonga/plugin.h>cxx . . $ `<file>/include/groonga/plugin.h`/
27
28 static grn_objcxx . . $ grn_obj# *
29 command_thread_limitcxx . . $ command_thread_limit(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx,
30 int n_args,
31 grn_objcxx . . $ grn_obj# **args,
32 grn_user_datacxx . . $ grn_user_data# *user_data)
33 {
34 grn_objcxx . . $ grn_obj# *max_bulk;
35 uint32_tcxx . . $ uint32_t# current_limit;
36
37 current_limit = grn_thread_get_limit_with_ctxcxx . . $ grn_thread_get_limit_with_ctx(42892115b099e3b9).(ctx);
38 GRN_OUTPUT_INT64cxx . . $ `lib/grn_output.h:101:9`!(current_limit);
39
40 max_bulk = grn_plugin_proc_get_varcxx . . $ grn_plugin_proc_get_var(3074f8d72b0d40ab).(ctx, user_data, "max", -1);
41 if (GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(max_bulk) > 0) {
42 uint32_tcxx . . $ uint32_t# max;
43 const char *max_text = GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(max_bulk);
44 const char *max_text_end;
45 const char *max_text_rest;
46
47 max_text_end = max_text + GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(max_bulk);
48 max = grn_atouicxx . . $ grn_atoui(2da3fe788a18ce64).(max_text, max_text_end, &max_text_rest);
49 if (max_text_rest != max_text_end) {
50 ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_INVALID_ARGUMENT,
51 "[thread_limit] max must be unsigned integer value: <%.*s>",
52 (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(max_bulk),
53 max_text);
54 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
55 }
56 if (max == 0) {
57 ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_INVALID_ARGUMENT,
58 "[thread_limit] max must be 1 or larger: <%.*s>",
59 (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(max_bulk),
60 max_text);
61 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
62 }
63 grn_thread_set_limit_with_ctxcxx . . $ grn_thread_set_limit_with_ctx(969b9cdb234920c4).(ctx, max);
64 }
65
66 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
67 }
68
69 void
70 grn_proc_init_thread_limitcxx . . $ grn_proc_init_thread_limit(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx)
71 {
72 grn_expr_varcxx . . $ grn_expr_var# vars[1];
73 grn_plugin_expr_var_initcxx . . $ grn_plugin_expr_var_init(680ef4125f11597f).(ctx, &(vars[0]), "max", -1);
74 grn_plugin_command_createcxx . . $ grn_plugin_command_create(2dfd920bb40f3149).(ctx,
75 "thread_limit", -1,
76 command_thread_limitcxx . . $ command_thread_limit(fd082858389c8bb0).,
77 1,
78 vars);
79 }
80
81 static grn_objcxx . . $ grn_obj# *
82 command_thread_dumpcxx . . $ command_thread_dump(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx,
83 int n_args,
84 grn_objcxx . . $ grn_obj# **args,
85 grn_user_datacxx . . $ grn_user_data# *user_data)
86 {
87 grn_thread_dumpcxx . . $ grn_thread_dump(2b4fa601bf4f1e5b).(ctx);
88 GRN_OUTPUT_BOOLcxx . . $ `lib/grn_output.h:108:9`!(ctx->rc == GRN_SUCCESS);
89 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
90 }
91
92 void
93 grn_proc_init_thread_dumpcxx . . $ grn_proc_init_thread_dump(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx)
94 {
95 grn_plugin_command_createcxx . . $ grn_plugin_command_create(2dfd920bb40f3149).(ctx,
96 "thread_dump", -1,
97 command_thread_dumpcxx . . $ command_thread_dump(fd082858389c8bb0).,
98 0,
99 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
100 }