- Release send queue after the send thread is finished.
- Add new function to clear the data in the queue.
Signed-off-by: Jaeyun <jy1210.jung@samsung.com>
Signed-off-by: gichan <gichan2.jang@samsung.com>
eh->user_data = NULL;
eh->broker_h = NULL;
- nns_edge_queue_destroy (eh->send_queue);
- eh->send_queue = NULL;
-
+ nns_edge_queue_clear (eh->send_queue);
if (eh->send_thread) {
eh->sending = false;
pthread_join (eh->send_thread, NULL);
eh->send_thread = 0;
}
+ nns_edge_queue_destroy (eh->send_queue);
+ eh->send_queue = NULL;
if (eh->listener_thread) {
eh->listening = false;
return (popped && *data != NULL);
}
+
+/**
+ * @brief Clear all data in the queue.
+ * @note When this function is called, nns_edge_queue_wait_pop will stop the waiting.
+ */
+bool
+nns_edge_queue_clear (nns_edge_queue_h handle)
+{
+ nns_edge_queue_s *q = (nns_edge_queue_s *) handle;
+
+ if (!q) {
+ nns_edge_loge ("[Queue] Invalid param, queue is null.");
+ return false;
+ }
+
+ nns_edge_lock (q);
+ nns_edge_cond_signal (q);
+
+ while (q->length > 0U)
+ _pop_data (q, true, NULL, NULL);
+
+ nns_edge_unlock (q);
+ return true;
+}
*/
bool nns_edge_queue_wait_pop (nns_edge_queue_h handle, unsigned int timeout, void **data, nns_size_t *size);
+/**
+ * @brief Stop waiting for new data and clear all data in the queue.
+ * @param[in] handle The queue handle.
+ * @return true on success.
+ * @note When this function is called, nns_edge_queue_wait_pop will stop the waiting.
+ */
+bool nns_edge_queue_clear (nns_edge_queue_h handle);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */