Upload packaging folder
[platform/upstream/iotjs.git] / src / module / iotjs_module_timer.h
1 /* Copyright 2015-present Samsung Electronics Co., Ltd. and other contributors
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 #ifndef IOTJS_MODULE_TIMER_H
17 #define IOTJS_MODULE_TIMER_H
18
19
20 #include "iotjs_binding.h"
21 #include "iotjs_handlewrap.h"
22
23
24 typedef struct {
25   iotjs_handlewrap_t handlewrap;
26   uv_timer_t handle;
27 } IOTJS_VALIDATED_STRUCT(iotjs_timerwrap_t);
28
29
30 iotjs_timerwrap_t* iotjs_timerwrap_create(const iotjs_jval_t* jtimer);
31
32 iotjs_timerwrap_t* iotjs_timerwrap_from_jobject(const iotjs_jval_t* jtimer);
33 iotjs_timerwrap_t* iotjs_timerwrap_from_handle(uv_timer_t* timer_handle);
34
35 uv_timer_t* iotjs_timerwrap_handle(iotjs_timerwrap_t* timerwrap);
36 iotjs_jval_t* iotjs_timerwrap_jobject(iotjs_timerwrap_t* timerwrap);
37
38 // Start timer.
39 int iotjs_timerwrap_start(iotjs_timerwrap_t* timerwrap, int64_t timeout,
40                           int64_t repeat);
41 // Stop & close timer.
42 int iotjs_timerwrap_stop(iotjs_timerwrap_t* timerwrap);
43
44
45 #endif /* IOTJS_MODULE_TIMER_H */