Added an API to check io condtion. 66/254766/1
authorJoonbum Ko <joonbum.ko@samsung.com>
Mon, 9 Nov 2020 05:19:52 +0000 (14:19 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Tue, 9 Mar 2021 08:44:19 +0000 (17:44 +0900)
Change-Id: I493b57bd93096fe433cd6db521563cacd8d47a3c
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
src/tpl_utils_gthread.c
src/tpl_utils_gthread.h

index 181bf31..66e7b23 100644 (file)
@@ -285,6 +285,23 @@ tpl_gsource_get_data(tpl_gsource *source)
                return source->data;
 }
 
+tpl_bool_t
+tpl_gsource_check_io_condition(tpl_gsource *source)
+{
+       GIOCondition cond;
+
+       if (!source) {
+               TPL_ERR("Invalid parameter tpl_gsource is null");
+               return TPL_FALSE;
+       }
+
+       cond = g_source_query_unix_fd(source->gsource, source->tag);
+       if (cond & G_IO_IN)
+               return TPL_TRUE;
+
+       return TPL_FALSE;
+}
+
 void
 tpl_gmutex_init(tpl_gmutex *gmutex)
 {
index 1886609..084754c 100644 (file)
@@ -106,6 +106,15 @@ void *
 tpl_gsource_get_data(tpl_gsource *source);
 
 /**
+ * Check the GIOCondition of fd that tpl_gsource has
+ *
+ * @param source Pointer to tpl_gsource to check io condition.
+ * @return TPL_TRUE if GIOCondition is G_IO_IN, TPL_FALSE otherwise (G_IO_ERR).
+ */
+tpl_bool_t
+tpl_gsource_check_io_condition(tpl_gsource *source);
+
+/**
  * wrapping g_mutex_init()
  *
  * @param gmutex Pointer to tpl_gmutex.