[Filter/Sub] use glib-mutex
authorJaeyun <jy1210.jung@samsung.com>
Tue, 17 Sep 2019 07:10:23 +0000 (16:10 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Tue, 17 Sep 2019 11:34:15 +0000 (20:34 +0900)
remove pthread header and use g_mutex instead.

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
ext/nnstreamer/tensor_filter/tensor_filter_python_core.cc
ext/nnstreamer/tensor_filter/tensor_filter_python_core.h

index 73cc457..eced0e3 100644 (file)
@@ -106,7 +106,7 @@ PYCore::PYCore (const char* _script_path, const char* _custom)
   configured = false;
 
   /** to prevent concurrent Python C-API calls */
-  pthread_mutex_init(&py_mutex, NULL);
+  g_mutex_init (&py_mutex);
 }
 
 /**
@@ -127,6 +127,7 @@ PYCore::~PYCore ()
   Py_Finalize();
 
   dlclose(handle);
+  g_mutex_clear (&py_mutex);
 }
 
 /**
index 38f6901..5defe8d 100644 (file)
@@ -31,7 +31,6 @@
 #include <glib.h>
 #include <string.h>
 #include <dlfcn.h>
-#include <pthread.h>
 #include <structmember.h>
 
 #include "nnstreamer_plugin_api_filter.h"
@@ -76,9 +75,9 @@ public:
   /** @brief Return callback type */
   cb_type getCbType () { return callback_type; }
   /** @brief Lock python-related actions */
-  void Py_LOCK() { pthread_mutex_lock(&py_mutex); }
+  void Py_LOCK() { g_mutex_lock (&py_mutex); }
   /** @brief Unlock python-related actions */
-  void Py_UNLOCK() { pthread_mutex_unlock(&py_mutex); }
+  void Py_UNLOCK() { g_mutex_unlock (&py_mutex); }
 
   PyObject* PyTensorShape_New (const GstTensorInfo *info);
 
@@ -100,7 +99,7 @@ private:
 
   PyObject* core_obj;
   PyObject* shape_cls;
-  pthread_mutex_t py_mutex;
+  GMutex py_mutex;
 
   GstTensorsInfo inputTensorMeta;  /**< The tensor info of input tensors */
   GstTensorsInfo outputTensorMeta;  /**< The tensor info of output tensors */