Renamed variables and functions of Notification consumer. 79/8379/2
authorKIM JungYong <jyong2.kim@samsung.com>
Mon, 30 May 2016 06:14:38 +0000 (15:14 +0900)
committerUze Choi <uzchoi@samsung.com>
Tue, 31 May 2016 02:22:30 +0000 (02:22 +0000)
a couple of variables and function is renamed.
in particular, processing function of queue task in each submodules renamed
to TaskProcessing and thread structure is renamed to NSThread from NSThreadHandle.
and thread join function is added.

Change-Id: Id1508e3f6422318f316ee388cf195217d0823ebd
Signed-off-by: KIM JungYong <jyong2.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/8379
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
14 files changed:
service/notification/src/consumer/NSConsumerCommon.c
service/notification/src/consumer/NSConsumerCommon.h
service/notification/src/consumer/NSConsumerDiscovery.c
service/notification/src/consumer/NSConsumerDiscovery.h
service/notification/src/consumer/NSConsumerListener.c
service/notification/src/consumer/NSConsumerMessageHandler.c
service/notification/src/consumer/NSConsumerNotification.c
service/notification/src/consumer/NSConsumerNotification.h
service/notification/src/consumer/NSConsumerQueue.c
service/notification/src/consumer/NSConsumerQueue.h
service/notification/src/consumer/NSConsumerSubsription.c
service/notification/src/consumer/NSConsumerSubsription.h
service/notification/src/consumer/NSThread.c
service/notification/src/consumer/NSThread.h

index 2f37bea..e5ed593 100644 (file)
@@ -253,7 +253,7 @@ void NSRemoveMessage(NSMessage_consumer * msg)
     msg = NULL;
 }
 
-OCStackResult NSRequestToResourceIntrospection(OCDoHandle * handle,
+OCStackResult NSSendRequest(OCDoHandle * handle,
         OCMethod method, const OCDevAddr * addr,
         const char * queryUrl, OCPayload * payload, void * callback)
 {
index 6832009..ddc94a7 100644 (file)
@@ -88,7 +88,7 @@ NSResult NSConsumerPushEvent(NSTask *);
 NSMessage_consumer * NSCopyMessage(NSMessage_consumer *);
 void NSRemoveMessage(NSMessage_consumer *);
 
-OCStackResult NSRequestToResourceIntrospection(OCDoHandle * handle,
+OCStackResult NSSendRequest(OCDoHandle * handle,
         OCMethod method, const OCDevAddr * addr,
         const char * queryUrl, OCPayload * payload, void * callback);
 
index 0eed05c..2e44986 100644 (file)
@@ -66,7 +66,7 @@ OCStackApplicationResult NSConsumerPresenceListener(
 
     else if (payload->trigger == OC_PRESENCE_TRIGGER_CREATE)
     {
-    NSRequestToResourceIntrospection(NULL, OC_REST_DISCOVER, clientResponse->addr,
+    NSSendRequest(NULL, OC_REST_DISCOVER, clientResponse->addr,
             NS_DISCOVER_QUERY, NULL, NSProviderDiscoverListener);
     }
 
@@ -99,9 +99,9 @@ OCStackApplicationResult NSProviderDiscoverListener(
     {
         if (!strcmp(resource->uri, NS_RESOURCE_URI))
         {
-            NSRequestToResourceIntrospection(
+            NSSendRequest(
                     NULL, OC_REST_GET, clientResponse->addr,
-                    NS_RESOURCE_URI, NULL, NSGetProviderInformation);
+                    NS_RESOURCE_URI, NULL, NSIntrospectProvider);
         }
         resource = resource->next;
     }
@@ -109,7 +109,7 @@ OCStackApplicationResult NSProviderDiscoverListener(
     return OC_STACK_KEEP_TRANSACTION;
 }
 
-OCStackApplicationResult NSGetProviderInformation(
+OCStackApplicationResult NSIntrospectProvider(
         OCDoHandle handle, OCClientResponse * clientResponse)
 {
     (void) handle;
@@ -211,7 +211,7 @@ OCStackApplicationResult NSGetProviderInformation(
     return OC_STACK_KEEP_TRANSACTION;
 }
 
-void NSConsumerDiscoveryHandleMsg(NSTask * task)
+void NSConsumerDiscoveryTaskProcessing(NSTask * task)
 {
     if (!task)
     {
@@ -222,7 +222,7 @@ void NSConsumerDiscoveryHandleMsg(NSTask * task)
     NS_LOG_V(DEBUG, "Receive Event : %d", (int)task->taskType);
     if (task->taskType == TASK_EVENT_CONNECTED || task->taskType == TASK_CONSUMER_REQ_DISCOVER)
     {
-        NSRequestToResourceIntrospection(NULL, OC_REST_DISCOVER, NULL, NS_DISCOVER_QUERY,
+        NSSendRequest(NULL, OC_REST_DISCOVER, NULL, NS_DISCOVER_QUERY,
                 NULL, NSProviderDiscoverListener);
     }
     else
index a85030b..8c0d695 100644 (file)
@@ -30,7 +30,7 @@ extern "C" {
 #include "ocstack.h"
 #include "NSStructs.h"
 
-void NSConsumerDiscoveryHandleMsg(NSTask *);
+void NSConsumerDiscoveryTaskProcessing(NSTask *);
 
 OCStackApplicationResult NSConsumerPresenceListener(OCDoHandle, OCClientResponse *);
 
@@ -38,7 +38,7 @@ OCStackApplicationResult NSConsumerPresenceListener(OCDoHandle, OCClientResponse
 OCStackApplicationResult NSProviderDiscoverListener(OCDoHandle, OCClientResponse *);
 
 // for checking Permission
-OCStackApplicationResult NSGetProviderInformation(OCDoHandle, OCClientResponse *);
+OCStackApplicationResult NSIntrospectProvider(OCDoHandle, OCClientResponse *);
 
 #ifdef __cplusplus
 }
index 71f2e8d..ad06647 100644 (file)
@@ -54,14 +54,14 @@ NSResult NSConsumerListenerInit()
 //        return NS_ERROR;
 //    }
 
-    if (OC_STACK_OK != NSRequestToResourceIntrospection(NULL, OC_REST_PRESENCE, NULL,
+    if (OC_STACK_OK != NSSendRequest(NULL, OC_REST_PRESENCE, NULL,
             NS_PRESENCE_SUBSCRIBE_QUERY, NULL, NSConsumerPresenceListener))
     {
         NS_LOG(ERROR, "Presence request fail");
         return NS_ERROR;
     }
 
-    if (OC_STACK_OK != NSRequestToResourceIntrospection(NULL, OC_REST_DISCOVER, NULL,
+    if (OC_STACK_OK != NSSendRequest(NULL, OC_REST_DISCOVER, NULL,
             NS_DISCOVER_QUERY, NULL, NSProviderDiscoverListener))
     {
         NS_LOG(ERROR, "Discover request fail");
index 1920214..9735455 100644 (file)
@@ -42,15 +42,15 @@ void * NSConsumerMsgHandleThreadFunc(void * handle);
 
 void * NSConsumerMsgPushThreadFunc(void * data);
 
-void NSConsumerHandleMsg(NSTask * task);
+void NSConsumerTaskProcessing(NSTask * task);
 
-NSThreadHandle ** NSGetMsgHandleThreadHandle()
+NSThread ** NSGetMsgHandleThreadHandle()
 {
-    static NSThreadHandle * handle = NULL;
+    static NSThread * handle = NULL;
     return & handle;
 }
 
-void NSSetMsgHandleThreadHandle(NSThreadHandle * handle)
+void NSSetMsgHandleThreadHandle(NSThread * handle)
 {
    *(NSGetMsgHandleThreadHandle()) = handle;
 }
@@ -68,7 +68,7 @@ void NSSetMsgHandleQueue(NSConsumerQueue * queue)
 
 NSResult NSConsumerMessageHandlerInit()
 {
-    NSThreadHandle * handle = NULL;
+    NSThread * handle = NULL;
     NSConsumerQueue * queue = NULL;
 
     if (NS_OK != NSConsumerListenerInit())
@@ -123,7 +123,7 @@ void * NSConsumerMsgHandleThreadFunc(void * threadHandle)
 {
     NSConsumerQueue * queue = NULL;
     NSConsumerQueueObject * obj = NULL;
-    NSThreadHandle * handle = (NSThreadHandle *) threadHandle;
+    NSThread * handle = (NSThread *) threadHandle;
     NS_LOG(DEBUG, "created thread for consumer message handle");
     if (!handle)
     {
@@ -145,7 +145,7 @@ void * NSConsumerMsgHandleThreadFunc(void * threadHandle)
             continue;
         }
 
-        if (NSIsEmptyQueue(queue))
+        if (NSIsQueueEmpty(queue))
         {
             continue;
         }
@@ -156,7 +156,7 @@ void * NSConsumerMsgHandleThreadFunc(void * threadHandle)
 
         if (obj)
         {
-            NSConsumerHandleMsg((NSTask *)(obj->data));
+            NSConsumerTaskProcessing((NSTask *)(obj->data));
         }
 
         NSThreadUnlock(handle);
@@ -170,8 +170,8 @@ void * NSConsumerMsgPushThreadFunc(void * data)
 {
     NSConsumerQueueObject * obj = NULL;
     NSConsumerQueue * queue = NULL;
-    NSThreadHandle * handle = *(NSGetMsgHandleThreadHandle());
-    if (!handle)
+    NSThread * msgHandleThread = *(NSGetMsgHandleThreadHandle());
+    if (!msgHandleThread)
     {
         NS_LOG(ERROR, "NSThreadHandle is null. can not insert to queue");
         return NULL;
@@ -187,7 +187,7 @@ void * NSConsumerMsgPushThreadFunc(void * data)
     obj->data = data;
     obj->next = NULL;
 
-    NSThreadLock(handle);
+    NSThreadLock(msgHandleThread);
 
     queue = *(NSGetMsgHandleQueue());
     if (!queue)
@@ -201,19 +201,19 @@ void * NSConsumerMsgPushThreadFunc(void * data)
         NSPushQueue(queue, obj);
     }
 
-    NSThreadUnlock(handle);
+    NSThreadUnlock(msgHandleThread);
 
     return NULL;
 }
 
-void NSConsumerHandleMsg(NSTask * task)
+void NSConsumerTaskProcessing(NSTask * task)
 {
     switch (task->taskType)
     {
     case TASK_EVENT_CONNECTED:
     case TASK_CONSUMER_REQ_DISCOVER:
     {
-        NSConsumerDiscoveryHandleMsg(task);
+        NSConsumerDiscoveryTaskProcessing(task);
         break;
     }
     case TASK_CONSUMER_REQ_SUBSCRIBE:
@@ -221,14 +221,14 @@ void NSConsumerHandleMsg(NSTask * task)
     case TASK_SEND_READ:
     case TASK_SEND_DISMISS:
     {
-        NSConsumerNotificationHandleMsg(task);
+        NSConsumerNotificationTaskProcessing(task);
         break;
     }
     case TASK_RECV_READ:
     case TASK_RECV_DISMISS:
     case TASK_CONSUMER_RECV_NOTIFICATION:
     {
-        NSConsumerSubscriptionHandleMsg(task);
+        NSConsumerSubscriptionTaskProcessing(task);
         break;
     }
     default:
index fcdbf64..d19ea9b 100644 (file)
@@ -36,14 +36,14 @@ NSResult NSPushToCache(OCClientResponse * clientResponse, NSTaskType type);
 
 NSResult NSConsumerSubscribeProvider(NSProvider * provider)
 {
-    if (OC_STACK_OK != NSRequestToResourceIntrospection(&(provider->messageHandle),
+    if (OC_STACK_OK != NSSendRequest(&(provider->messageHandle),
             OC_REST_OBSERVE, (OCDevAddr *) provider->mUserData,
             provider->messageUri, NULL, NSConsumerNotificationListener))
     {
         return NS_ERROR;
     }
 
-    if (OC_STACK_OK != NSRequestToResourceIntrospection(&(provider->syncHandle),
+    if (OC_STACK_OK != NSSendRequest(&(provider->syncHandle),
             OC_REST_OBSERVE, (OCDevAddr *) provider->mUserData,
             provider->syncUri, NULL, NSConsumerSyncListener))
     {
@@ -56,7 +56,7 @@ NSResult NSConsumerSubscribeProvider(NSProvider * provider)
 NSResult NSConsumerPostProvider(OCDevAddr * addr, OCPayload * payload, const char * uri)
 {
 
-    if (OC_STACK_OK != NSRequestToResourceIntrospection(NULL, OC_REST_POST, addr,
+    if (OC_STACK_OK != NSSendRequest(NULL, OC_REST_POST, addr,
             uri, payload, NULL))
     {
         return NS_ERROR;
@@ -272,7 +272,7 @@ NSProvider * NSGetProvider(OCClientResponse * clientResponse)
     return newProvider;
 }
 
-void NSConsumerNotificationHandleMsg(NSTask * task)
+void NSConsumerNotificationTaskProcessing(NSTask * task)
 {
     if (!task)
     {
index 289d6d4..b302f89 100644 (file)
@@ -31,7 +31,7 @@ extern "C" {
 #include "NSStructs.h"
 #include "ocstack.h"
 
-void NSConsumerNotificationHandleMsg(NSTask *);
+void NSConsumerNotificationTaskProcessing(NSTask *);
 
 NSResult NSConsumerSubscribeProvider(NSProvider *);
 NSResult NSConsumerPostProvider(OCDevAddr *, OCPayload *, const char *);
index f37bec6..a2c9b53 100644 (file)
@@ -116,7 +116,7 @@ int NSGetQueueSize(NSConsumerQueue * queue)
     return queue->size;
 }
 
-bool NSIsEmptyQueue(NSConsumerQueue * queue)
+bool NSIsQueueEmpty(NSConsumerQueue * queue)
 {
     return (queue->size <= 0);
 }
index 73ee8c6..55c9223 100644 (file)
@@ -50,7 +50,7 @@ NSConsumerQueueObject * NSPopQueue(NSConsumerQueue *);
 
 int NSGetQueueSize(NSConsumerQueue *);
 
-bool NSIsEmptyQueue(NSConsumerQueue *);
+bool NSIsQueueEmpty(NSConsumerQueue *);
 
 #ifdef __cplusplus
 }
index 018cfaf..791320a 100644 (file)
@@ -72,7 +72,7 @@ NSResult NSCacheUpdate(NSCacheList * cache, NSTask * task, NSConsumerMessageType
     return NS_OK;
 }
 
-void NSConsumerSubscriptionHandleMsg(NSTask * task)
+void NSConsumerSubscriptionTaskProcessing(NSTask * task)
 {
     if (!task)
     {
index d7dd026..f303c49 100644 (file)
@@ -31,7 +31,7 @@ extern "C" {
 
 void NSDestroyCacheList();
 
-void NSConsumerSubscriptionHandleMsg(NSTask *);
+void NSConsumerSubscriptionTaskProcessing(NSTask *);
 
 #ifdef __cplusplus
 }
index 810e176..aca5038 100644 (file)
@@ -26,9 +26,9 @@
 #include <memory.h>
 #include "oic_malloc.h"
 
-void NSDestroyThreadHandle(NSThreadHandle *);
+void NSDestroyThreadHandle(NSThread *);
 
-NSThreadHandle * NSThreadInit(NSThreadFunc func, void * data)
+NSThread * NSThreadInit(NSThreadFunc func, void * data)
 {
     if (!func)
     {
@@ -36,14 +36,14 @@ NSThreadHandle * NSThreadInit(NSThreadFunc func, void * data)
         return NULL;
     }
 
-    NSThreadHandle * handle = (NSThreadHandle *)OICMalloc(sizeof(NSThreadHandle));
+    NSThread * handle = (NSThread *)OICMalloc(sizeof(NSThread));
     if (!handle)
     {
         NS_LOG(ERROR, "thread allocation fail");
         return NULL;
     }
 
-    memset(handle, 0, sizeof(NSThreadHandle));
+    memset(handle, 0, sizeof(NSThread));
 
     pthread_mutexattr_init(&(handle->mutex_attr));
     if (pthread_mutexattr_settype(&(handle->mutex_attr), PTHREAD_MUTEX_RECURSIVE))
@@ -82,29 +82,34 @@ NSThreadHandle * NSThreadInit(NSThreadFunc func, void * data)
     return handle;
 }
 
-void NSThreadLock(NSThreadHandle * handle)
+void NSThreadLock(NSThread * handle)
 {
     pthread_mutex_lock(&(handle->mutex));
 }
 
-void NSThreadUnlock(NSThreadHandle * handle)
+void NSThreadUnlock(NSThread * handle)
 {
     pthread_mutex_unlock(&(handle->mutex));
 }
 
-void NSThreadStop(NSThreadHandle * handle)
+void NSThreadStop(NSThread * handle)
 {
     NSDestroyThreadHandle(handle);
 }
 
-void NSDestroyThreadHandle(NSThreadHandle * handle)
+void NSThreadJoin(NSThread * handle)
+{
+       if (handle->thread_id)
+       {
+               pthread_join(handle->thread_id, NULL);
+       }
+}
+
+void NSDestroyThreadHandle(NSThread * handle)
 {
     handle->isStarted = false;
 
-    if (handle->thread_id)
-    {
-        pthread_join(handle->thread_id, NULL);
-    }
+    NSThreadJoin(handle);
 
     pthread_mutex_destroy(&(handle->mutex));
     pthread_mutexattr_destroy(&(handle->mutex_attr));
index 54c7a2e..e4d0bc3 100644 (file)
@@ -43,18 +43,20 @@ typedef struct
     pthread_t thread_id;
     pthread_mutex_t mutex;
     pthread_mutexattr_t mutex_attr;
-} NSThreadHandle;
+} NSThread;
 #endif
 
 typedef void *(*NSThreadFunc)(void *);
 
-NSThreadHandle * NSThreadInit(NSThreadFunc, void *);
+NSThread * NSThreadInit(NSThreadFunc, void *);
 
-void NSThreadLock(NSThreadHandle *);
+void NSThreadLock(NSThread *);
 
-void NSThreadUnlock(NSThreadHandle *);
+void NSThreadUnlock(NSThread *);
 
-void NSThreadStop(NSThreadHandle *);
+void NSThreadJoin(NSThread *);
+
+void NSThreadStop(NSThread *);
 
 #ifdef __cplusplus
 }