1 /******************************************************************
3 * Copyright 2014 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
21 * @file caqueueingthread.h
22 * @brief This file contains common utility function for handling message ques
24 #ifndef __CA_THREAD_H_
25 #define __CA_THREAD_H_
29 #include "uthreadpool.h"
38 /**Thread function to be invoked**/
39 typedef void (*CAThreadTask)(void *threadData);
41 /**Data destroy function**/
42 typedef void (*CADataDestroyFunction)(void *data, uint32_t size);
46 /** Thread pool of the thread started **/
47 u_thread_pool_t threadPool;
48 /** mutex for synchrnoization **/
50 /** conditional mutex for synchrnoization **/
52 /**Thread function to be invoked**/
53 CAThreadTask threadTask;
54 /**Data destroy function**/
55 CADataDestroyFunction destroy;
56 /** Variable to inform the thread to stop **/
58 /** Que on which the thread is operating. **/
63 * @brief Initializes the queing thread
64 * @param thread [IN] thread data for each thread
65 * @param handle [IN] thread pool handle created
66 * @param task [IN] function to be called for reach data
67 * @param destroy [IN] function to data destroy
68 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
70 CAResult_t CAQueueingThreadInitialize(CAQueueingThread_t *thread, u_thread_pool_t handle,
71 CAThreadTask task, CADataDestroyFunction destroy);
74 * @brief Starting the queueing thread
75 * @param thread [IN] thread data that needs to be started
76 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
78 CAResult_t CAQueueingThreadStart(CAQueueingThread_t *thread);
81 * @brief Add queueing thread data for new thread
82 * @param thread [IN] thread data for new thread control
83 * @param data [IN] data that needs to be given for each thread
84 * @param size [IN] length of the data
85 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
87 CAResult_t CAQueueingThreadAddData(CAQueueingThread_t *thread, void *data, uint32_t size);
90 * @brief Stopping the queueing thread
91 * @param thread [IN] thread data that needs to be started
92 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
95 CAResult_t CAQueueingThreadStop(CAQueueingThread_t *thread);
98 * @brief Terminating the queing thread
99 * @param thread [IN] thread data for each thread
100 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
103 CAResult_t CAQueueingThreadDestroy(CAQueueingThread_t *thread);
109 #endif // __CA_THREAD_H_