Fix double close issue
[platform/core/appfw/aul-1.git] / src / aul_worker.h
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __AUL_WORKER_H__
18 #define __AUL_WORKER_H__
19
20 #include <stdbool.h>
21
22 typedef void *aul_worker_h;
23
24 typedef enum {
25         AUL_IO_IN = 0x01,
26         AUL_IO_OUT = 0x02,
27         AUL_IO_PRI = 0x04,
28         AUL_IO_ERR = 0x10,
29         AUL_IO_HUP = 0x20,
30         AUL_IO_NVAL = 0x40,
31 } aul_io_condition_e;
32
33 typedef bool (*aul_worker_io_job_cb)(int fd, int condition, void *user_data);
34
35 aul_worker_h aul_worker_create(const char *name);
36
37 void aul_worker_destroy(aul_worker_h handle);
38
39 int aul_worker_add_io_job(aul_worker_h handle, const char *job_name,
40                 int fd, int condition, bool do_close,
41                 aul_worker_io_job_cb callback, void *user_data);
42
43 void aul_worker_remove_io_job(aul_worker_h handle, int fd);
44
45 int aul_worker_add_anr_timer(aul_worker_h handle,
46                 int cmd, unsigned int timeout);
47
48 int aul_worker_remove_anr_timer(aul_worker_h handle);
49
50 #endif /* __AUL_WORKER_H__ */