bdd53a15c356b1014033fceac8625bc645b50ad3
[apps/native/ttsd-worker-task.git] / src / worker.h
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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 __WORKER_H_
18 #define __WORKER_H_
19
20 #include "task.h"
21
22 /**
23  * @brief Worker structure.
24  */
25 typedef struct worker worker_t;
26
27 /**
28  * @brief Worker mode enumeration.
29  */
30 typedef enum worker_mode
31 {
32     /**
33      * @brief In this mode worker busy to idle proportion is low.
34      */
35     MODE_LOW,
36
37     /**
38      * @brief In this mode worker busy to idle proportion is balanced.
39      */
40     MODE_MEDIUM,
41
42     /**
43      * @brief In this mode worker busy to idle proportion is high.
44      */
45     MODE_HIGH
46 } worker_mode_e;
47
48 /**
49  * @brief Creates worker.
50  */
51 worker_t *worker_create();
52
53 /**
54  * @brief Destroys worker.
55  */
56 void worker_destroy();
57
58 /**
59  * @brief Sets maximum number of threads that worker can use.
60  * @param[in] worker Worker reference.
61  * @param[in] max_threads Maximum number of threads that worker can use.
62  */
63 void worker_set_max_num_of_threads(worker_t *worker, int max_threads);
64
65 /**
66  * @brief Adds new task to task queue.
67  * @param[in] worker Worker reference.
68  * @param[in] task Task to do.
69  */
70 int worker_enqueue_task(worker_t *worker, task_t task);
71
72 /**
73  * @brief Sets worker mode.
74  * @param[in] worker Worker reference.
75  */
76 void worker_set_mode(worker_t *worker, worker_mode_e mode);
77
78 /**
79  * @brief Gets worker mode.
80  * @param[in] worker Worker reference.
81  */
82 worker_mode_e worker_get_mode(worker_t *worker);
83
84 #endif