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 181bf31f9e9f51b70d7c6d0af27835774407ab15..66e7b231acaa6e208568468c2213b2acbc5ee8b5 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 18866093d8a0a280b0c0b6ab3db40657b1d37193..084754c4df7e03ad73dcb3b570e1510c89c55f28 100644 (file)
@@ -105,6 +105,15 @@ tpl_gsource_send_event(tpl_gsource *source, uint64_t message);
 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()
  *