--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TT_DAEMON_QUEUE_H__
+#define __TT_DAEMON_QUEUE_H__
+
+typedef enum {
+ TTD_QUEUE_TYPE_CMD,
+ TTD_QUEUE_TYPE_RESULT,
+} ttd_queue_type_e;
+
+int ttd_queue_fini(void);
+int ttd_queue_init(void);
+int ttd_queue_push(ttd_queue_type_e type, void *data);
+int ttd_queue_pop(ttd_queue_type_e type, void **data);
+void *ttd_queue_timeout_pop(ttd_queue_type_e type, unsigned int timeout);
+
+#endif /* __TT_DAEMON_QUEUE_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <stdlib.h>
+#include "ttd-log.h"
+#include "ttd-queue.h"
+
+static GAsyncQueue *queue_cmd = NULL;
+static GAsyncQueue *queue_res = NULL;
+
+static void _cmd_queue_item_free(gpointer data)
+{
+ /* TODO */
+ free(data);
+}
+
+static void _res_queue_item_free(gpointer data)
+{
+ /* TODO */
+ free(data);
+}
+
+int ttd_queue_init(void)
+{
+ queue_cmd = g_async_queue_new_full(_cmd_queue_item_free);
+ queue_res = g_async_queue_new_full(_res_queue_item_free);
+
+ if (!(queue_cmd && queue_res)) {
+ _E("failed to create queue - cmd[%p], res[%p]", queue_cmd, queue_res);
+ return -1;
+ }
+
+ return 0;
+}
+
+int ttd_queue_fini(void)
+{
+ if (queue_cmd) {
+ g_async_queue_unref(queue_cmd);
+ queue_cmd = NULL;
+ }
+
+ if (queue_res) {
+ g_async_queue_unref(queue_res);
+ queue_res = NULL;
+ }
+
+ return 0;
+}
+
+int ttd_queue_push(ttd_queue_type_e type, void *data)
+{
+ GAsyncQueue *queue = NULL;
+
+ if (data == NULL) {
+ _E("data is NULL");
+ return -1;
+ }
+
+ switch (type) {
+ case TTD_QUEUE_TYPE_CMD:
+ if (!queue_cmd) {
+ _E("queue_cmd is not initialized yet");
+ return -1;
+ }
+ queue = queue_cmd;
+ break;
+ case TTD_QUEUE_TYPE_RESULT:
+ if (!queue_res) {
+ _E("queue_res is not initialized yet");
+ return -1;
+ }
+ queue = queue_res;
+ break;
+ }
+
+ _V("pushing data[%p] to queue[type - %d]", data, type);
+ g_async_queue_push(queue, data);
+
+ return 0;
+}
+
+static GAsyncQueue *__get_queue(ttd_queue_type_e type)
+{
+ GAsyncQueue *queue = NULL;
+ switch (type) {
+ case TTD_QUEUE_TYPE_CMD:
+ if (!queue_cmd) {
+ _E("queue_cmd is not initialized yet");
+ return NULL;
+ }
+ queue = queue_cmd;
+ break;
+ case TTD_QUEUE_TYPE_RESULT:
+ if (!queue_res) {
+ _E("queue_res is not initialized yet");
+ return NULL;
+ }
+ queue = queue_res;
+ break;
+ }
+
+ return queue;
+}
+
+int ttd_queue_pop(ttd_queue_type_e type, void **data)
+{
+ GAsyncQueue *queue = NULL;
+ void *item = NULL;
+
+ retvm_if(!data, -1, "data is NULL");
+
+ queue = __get_queue(type);
+ retv_if(!queue, -1);
+
+ item = g_async_queue_pop(queue);
+ *data = item;
+
+ return 0;
+}
+
+void *ttd_queue_timeout_pop(ttd_queue_type_e type, unsigned int timeout_msec)
+{
+ GAsyncQueue *queue = NULL;
+ void *item = NULL;
+
+ queue = __get_queue(type);
+ retv_if(!queue, NULL);
+
+ item = g_async_queue_timeout_pop(queue, (guint64)timeout_msec*1000);
+
+ return item;
+}