Debian Codegraph @

lib/proc/proc_sleep.c

raw symbols SCIP
1 /*
2 Copyright (C) 2022 Sutou Kouhei <[email protected]>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
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_proc.h"
20
21 #include <groonga/plugin.h>
22
23 static grn_obj *
24 command_sleep(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
25 {
26 double second = grn_plugin_proc_get_var_double(ctx, user_data,
27 "second", -1,
28 1);
29 grn_nanosleep((uint64_t)(second * 1000000000));
30 grn_ctx_output_bool(ctx, true);
31 return NULL;
32 }
33
34 void
35 grn_proc_init_sleep(grn_ctx *ctx)
36 {
37 grn_expr_var vars[1];
38 grn_plugin_expr_var_init(ctx, &(vars[0]), "second", -1);
39 grn_plugin_command_create(ctx,
40 "sleep", -1,
41 command_sleep,
42 sizeof(vars) / sizeof(vars[0]),
43 vars);
44 }