From: ch79.cho Date: Mon, 8 Aug 2016 12:41:12 +0000 (+0900) Subject: Create topic module running with scheduler X-Git-Tag: 1.2.0+RC1~52^2~79 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2f1f2ee1c1e8b2411ec4bd897b582160b26bce28;p=platform%2Fupstream%2Fiotivity.git Create topic module running with scheduler Add topic feature module that works with its scheduler. Three tasks for topic notification are created. Change-Id: Ie68595fe0d9a1c63a802aef64e94f61482b19286 Signed-off-by: ch79.cho Reviewed-on: https://gerrit.iotivity.org/gerrit/10153 Tested-by: jenkins-iotivity Reviewed-by: Madan Lanka --- diff --git a/service/notification/src/provider/NSProviderInterface.c b/service/notification/src/provider/NSProviderInterface.c index 3b8ca0e..cc783fc 100644 --- a/service/notification/src/provider/NSProviderInterface.c +++ b/service/notification/src/provider/NSProviderInterface.c @@ -249,7 +249,7 @@ NSTopicList * NSProviderGetTopics(char *consumerId) NSTopicList * topicList = NSInitializeTopicList(); OICStrcpy(topicList->consumerId, UUID_STRING_SIZE, consumerId); - // OICStrcpy(topicList->topics, sizeof(NSTopic), NSGetTopics(consumerId)); + OICStrcpy(topicList->topics, sizeof(NSTopic), NSGetTopics(consumerId)); pthread_mutex_unlock(&nsInitMutex); NS_LOG(DEBUG, "NSProviderGetTopics - OUT"); diff --git a/service/notification/src/provider/NSProviderTopic.c b/service/notification/src/provider/NSProviderTopic.c new file mode 100644 index 0000000..41aebb5 --- /dev/null +++ b/service/notification/src/provider/NSProviderTopic.c @@ -0,0 +1,82 @@ +//****************************************************************** +// +// Copyright 2016 Samsung Electronics All Rights Reserved. +// +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +#include "NSProviderTopic.h" + +NSTopicList * NSGetTopics(char *consumerId) +{ + NS_LOG(DEBUG, "NSGetTopics()"); + + NSTopicList * topicList; + + if(consumerId == NULL) + { + NS_LOG(DEBUG, "All registered topic list"); + } + else + { + NS_LOG_V(DEBUG, "Subscribed topic list for consumerId(%s)", consumerId); + } + + NS_LOG(DEBUG, "NSGetTopics() NS_OK"); + return topicList; +} + +void * NSTopicSchedule(void * ptr) +{ + if (ptr == NULL) + { + NS_LOG(DEBUG, "Create NSTopicSchedule"); + } + + while (NSIsRunning[TOPIC_SCHEDULER]) + { + sem_wait(&NSSemaphore[TOPIC_SCHEDULER]); + pthread_mutex_lock(&NSMutex[TOPIC_SCHEDULER]); + + if (NSHeadMsg[TOPIC_SCHEDULER] != NULL) + { + NSTask *node = NSHeadMsg[TOPIC_SCHEDULER]; + NSHeadMsg[TOPIC_SCHEDULER] = node->nextTask; + + switch (node->taskType) + { + case TASK_SEND_TOPICS: + NS_LOG(DEBUG, "CASE TASK_SEND_TOPICS : "); + break; + case TASK_SUBSCRIBE_TOPICS: + NS_LOG(DEBUG, "CASE TASK_SUBSCRIBE_TOPICS : "); + break; + case TASK_REGISTER_TOPICS: + NS_LOG(DEBUG, "CASE TASK_REGISTER_TOPICS : "); + break; + default: + break; + } + + OICFree(node); + } + + pthread_mutex_unlock(&NSMutex[TOPIC_SCHEDULER]); + } + + NS_LOG(DEBUG, "Destroy NSTopicSchedule"); + return NULL; +}