X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fconnectivity%2Finc%2Fcaqueueingthread.h;h=91deedafcbbf3e6e39a374fdd2700cec06feb476;hb=1e743d337b66bda0e44a5ca500d4d7178bb599b5;hp=b3d282d303525282f077a18fe1a9f900d6953782;hpb=0734f2d4a926a266e8f5a988834e4c25c2d8d11d;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/connectivity/inc/caqueueingthread.h b/resource/csdk/connectivity/inc/caqueueingthread.h index b3d282d..91deeda 100644 --- a/resource/csdk/connectivity/inc/caqueueingthread.h +++ b/resource/csdk/connectivity/inc/caqueueingthread.h @@ -30,7 +30,7 @@ #include #include "cathreadpool.h" -#include "camutex.h" +#include "octhread.h" #include "uqueue.h" #include "cacommon.h" #ifdef __cplusplus @@ -38,69 +38,92 @@ extern "C" { #endif -/**Thread function to be invoked**/ +/** Thread function to be invoked. **/ typedef void (*CAThreadTask)(void *threadData); -/**Data destroy function**/ +/** Data destroy function. **/ typedef void (*CADataDestroyFunction)(void *data, uint32_t size); +/** Context based Data destroy function. **/ +typedef bool (*CAContextDataDestroy)(void *data, uint32_t size, void *ctx); + typedef struct { - /** Thread pool of the thread started **/ + /** Thread pool of the thread started. **/ ca_thread_pool_t threadPool; - /** mutex for synchrnoization **/ - ca_mutex threadMutex; - /** conditional mutex for synchrnoization **/ - ca_cond threadCond; - /**Thread function to be invoked**/ + /** mutex for synchronization. **/ + oc_mutex threadMutex; + /** conditional mutex for synchronization. **/ + oc_cond threadCond; + /** Thread function to be invoked. **/ CAThreadTask threadTask; - /**Data destroy function**/ + /** Data destroy function. **/ CADataDestroyFunction destroy; - /** Variable to inform the thread to stop **/ + /** Variable to inform the thread to stop. **/ bool isStop; /** Que on which the thread is operating. **/ u_queue_t *dataQueue; } CAQueueingThread_t; /** - * @brief Initializes the queing thread - * @param thread [IN] thread data for each thread - * @param handle [IN] thread pool handle created - * @param task [IN] function to be called for each data - * @param destroy [IN] function to data destroy - * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h) + * Initializes the queuing thread. + * @param[in] thread thread data for each thread. + * @param[in] handle thread pool handle created. + * @param[in] task function to be called for each data. + * @param[in] destroy function to data destroy. + * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h). */ CAResult_t CAQueueingThreadInitialize(CAQueueingThread_t *thread, ca_thread_pool_t handle, CAThreadTask task, CADataDestroyFunction destroy); /** - * @brief Starting the queueing thread - * @param thread [IN] thread data that needs to be started - * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h) + * Start the queuing thread. + * @param[in] thread thread data that needs to be started. + * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h). */ +#ifndef __TIZENRT__ CAResult_t CAQueueingThreadStart(CAQueueingThread_t *thread); - +#else +CAResult_t CAQueueingThreadStart(CAQueueingThread_t *thread, const char *thread_name); +#endif /** - * @brief Add queueing thread data for new thread - * @param thread [IN] thread data for new thread control - * @param data [IN] data that needs to be given for each thread - * @param size [IN] length of the data - * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h) + * Add queuing thread data for new thread. + * @param[in] thread thread data for new thread control. + * @param[in] data data that needs to be given for each thread. + * @param[in] size length of the data. + * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h). */ CAResult_t CAQueueingThreadAddData(CAQueueingThread_t *thread, void *data, uint32_t size); /** - * @brief Stopping the queueing thread - * @param thread [IN] thread data that needs to be started - * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h) + * Clears queue thread data. + * @param[in] thread thread data for new thread control. + * @return ::CA_STATUS_OK or Appropriate error code. + */ +CAResult_t CAQueueingThreadClearData(CAQueueingThread_t *thread); + +/** + * Clears queue thread data of specific context. + * @param[in] thread thread data for new thread control. + * @param[in] callback Function which should return true if the data + * needs to be deleted, else returns false + * @param[in] ctx Data to pass to callback + */ +CAResult_t CAQueueingThreadClearContextData(CAQueueingThread_t *thread, + CAContextDataDestroy callback, void *ctx); + +/** + * Stop the queuing thread. + * @param[in] thread thread data that needs to be started. + * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h). */ CAResult_t CAQueueingThreadStop(CAQueueingThread_t *thread); /** - * @brief Terminating the queing thread - * @param thread [IN] thread data for each thread - * @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h) + * Terminate the queuing thread. + * @param[in] thread thread data for each thread. + * @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h). */ CAResult_t CAQueueingThreadDestroy(CAQueueingThread_t *thread);