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);
43 /** Thread pool of the thread started **/
44 u_thread_pool_t threadPool;
45 /** mutex for synchrnoization **/
47 /** conditional mutex for synchrnoization **/
49 /**Thread function to be invoked**/
50 CAThreadTask threadTask;
51 /** Variable to inform the thread to stop **/
53 /** Que on which the thread is operating. **/
58 * @brief Initializes the queing thread
59 * @param thread [IN] thread data for each thread
60 * @param handle [IN] thread pool handle created
61 * @param task [IN] function to be called for reach data
62 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
64 CAResult_t CAQueueingThreadInitialize(CAQueueingThread_t *thread, u_thread_pool_t handle,
68 * @brief Starting the queueing thread
69 * @param thread [IN] thread data that needs to be started
70 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
72 CAResult_t CAQueueingThreadStart(CAQueueingThread_t *thread);
75 * @brief Add queueing thread data for new thread
76 * @param thread [IN] thread data for new thread control
77 * @param data [IN] data that needs to be given for each thread
78 * @param size [IN] length of the data
79 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
81 CAResult_t CAQueueingThreadAddData(CAQueueingThread_t *thread, void *data, uint32_t size);
84 * @brief Stopping the queueing thread
85 * @param thread [IN] thread data that needs to be started
86 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
89 CAResult_t CAQueueingThreadStop(CAQueueingThread_t *thread);
92 * @brief Terminating the queing thread
93 * @param thread [IN] thread data for each thread
94 * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
97 CAResult_t CAQueueingThreadDestroy(CAQueueingThread_t *thread);
103 #endif // __CA_THREAD_H_