sensord: share the lock in physical sensors 67/57867/2
authorkibak.yoon <kibak.yoon@samsung.com>
Mon, 25 Jan 2016 11:33:32 +0000 (20:33 +0900)
committerKibak Yoon <kibak.yoon@samsung.com>
Mon, 25 Jan 2016 11:47:59 +0000 (03:47 -0800)
- lock the command flow and event flow using same mutex in
  physical_sensor

Change-Id: I8ed6c061448c56f0b09e1a6b45709c1ff8e311ca
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
src/server/physical_sensor.cpp
src/server/physical_sensor.h
src/server/sensor_base.cpp
src/server/sensor_base.h

index 71de409..3c6f697 100644 (file)
@@ -22,6 +22,8 @@
 
 #define UNKNOWN_NAME "UNKNOWN_SENSOR"
 
+cmutex physical_sensor::m_mutex;
+
 physical_sensor::physical_sensor()
 : m_sensor_device(NULL)
 {
index 2c7742f..5abc41b 100644 (file)
@@ -47,6 +47,8 @@ public:
        virtual int get_sensor_event(sensor_event_t **event);
 
 private:
+       static cmutex m_mutex;
+
        sensor_handle_t m_handle;
        sensor_device *m_sensor_device;
 
index 0ff9dd1..7096862 100644 (file)
@@ -49,7 +49,6 @@ sensor_type_t sensor_base::get_type(void)
 
 bool sensor_base::start()
 {
-       AUTOLOCK(m_mutex);
        AUTOLOCK(m_client_mutex);
 
        ++m_client;
@@ -70,7 +69,6 @@ bool sensor_base::start()
 
 bool sensor_base::stop(void)
 {
-       AUTOLOCK(m_mutex);
        AUTOLOCK(m_client_mutex);
 
        --m_client;
@@ -323,7 +321,6 @@ int sensor_base::get_permission(void)
 
 bool sensor_base::is_started(void)
 {
-       AUTOLOCK(m_mutex);
        AUTOLOCK(m_client_mutex);
 
        return m_started;
@@ -404,52 +401,6 @@ bool sensor_base::push(sensor_event_t *event, int event_length)
        return true;
 }
 
-/*
-bool sensor_base::push(const sensor_event_t &event)
-{
-       AUTOLOCK(m_client_mutex);
-
-       if (m_client <= 0)
-               return false;
-
-       sensor_event_queue::get_instance().push(event);
-       return true;
-}
-
-bool sensor_base::push(sensor_event_t *event)
-{
-       AUTOLOCK(m_client_mutex);
-
-       if (m_client <= 0)
-               return false;
-
-       sensor_event_queue::get_instance().push(event);
-       return true;
-}
-
-bool sensor_base::push(const sensorhub_event_t &event)
-{
-       AUTOLOCK(m_client_mutex);
-
-       if (m_client <= 0)
-               return false;
-
-       sensor_event_queue::get_instance().push(event);
-       return true;
-}
-
-bool sensor_base::push(sensorhub_event_t *event)
-{
-       AUTOLOCK(m_client_mutex);
-
-       if (m_client <= 0)
-               return false;
-
-       sensor_event_queue::get_instance().push(event);
-       return true;
-}
-*/
-
 unsigned long long sensor_base::get_timestamp(void)
 {
        struct timespec t;
index 7ac3e98..000dfad 100644 (file)
@@ -87,19 +87,11 @@ public:
 
        /* push event to queue */
        bool push(sensor_event_t *event, int event_length);
-       /*
-       bool push(const sensor_event_t &event);
-       bool push(sensor_event_t *event);
-       bool push(const sensorhub_event_t &event);
-       bool push(sensorhub_event_t *event);
-       */
 
        /* for sensorhub */
        virtual long set_command(unsigned int cmd, long value);
        virtual int send_sensorhub_data(const char* data, int data_len);
 protected:
-       cmutex m_mutex;
-
        void set_privilege(sensor_privilege_t privilege);
        void set_permission(int permission);