+ oc_mutex_unlock(thread->threadMutex);
+
+ return CA_STATUS_OK;
+}
+
+CAResult_t CAQueueingThreadClearData(CAQueueingThread_t *thread)
+{
+ if (NULL == thread)
+ {
+ OIC_LOG(ERROR, TAG, "thread instance is empty..");
+ return CA_STATUS_INVALID_PARAM;
+ }
+
+ OIC_LOG(DEBUG, TAG, "clear queue data..");
+
+ // mutex lock
+ oc_mutex_lock(thread->threadMutex);
+
+ // remove all remained list data.
+ while (u_queue_get_size(thread->dataQueue) > 0)
+ {
+ // get data
+ u_queue_message_t *message = u_queue_get_element(thread->dataQueue);
+
+ // free
+ if (NULL != message)
+ {
+ if (NULL != thread->destroy)
+ {
+ thread->destroy(message->msg, message->size);
+ }
+ else
+ {
+ OICFree(message->msg);
+ }
+
+ OICFree(message);
+ }
+ }
+
+ // mutex unlock
+ oc_mutex_unlock(thread->threadMutex);
+
+ return CA_STATUS_OK;
+}
+
+CAResult_t CAQueueingThreadClearContextData(CAQueueingThread_t *thread,
+ CAContextDataDestroy callback, void *ctx)
+{
+ if (NULL == thread)
+ {
+ OIC_LOG(ERROR, TAG, "thread instance is empty..");
+ return CA_STATUS_INVALID_PARAM;
+ }
+
+ if (NULL == callback)
+ {
+ OIC_LOG(ERROR, TAG, "callback is NULL..");
+ return CA_STATUS_INVALID_PARAM;
+ }
+
+ if (NULL == ctx)
+ {
+ OIC_LOG(ERROR, TAG, "ctx is NULL..");
+ return CA_STATUS_INVALID_PARAM;
+ }
+
+ OIC_LOG(DEBUG, TAG, "Clear thread data according to context");
+
+ // mutex lock
+ oc_mutex_lock(thread->threadMutex);
+
+ // remove adapter related list data.
+ u_queue_remove_req_elements(thread->dataQueue, callback, ctx, thread->destroy);
+
+ // mutex unlock
+ oc_mutex_unlock(thread->threadMutex);