Revision fb72e91b src/urt_topic.c

View differences:

src/urt_topic.c
60 60
  urtDebugAssert(topic);
61 61
  urtDebugAssert(mandatoryMessage);
62 62

  
63
  urt_topic_t.next = NULL;
64
  urt_topic_t.id = id;
65
  urtMutexInit(topic->lock);
66
  urtEventSourceInit(topic->evtSource);
67
  urt_topic_t.numHrtSubscribers = 0;
68
  urtCondvarInit(topic->hrtReleased);
63
  topic->next = NULL;
64
  topic->id = id;
65
  urtMutexInit(&topic->lock);
66
  urtEventSourceInit(&topic->evtSource);
67
  topic->numHrtSubscribers = 0;
68
  urtCondvarInit(&topic->hrtReleased);
69 69
  topic->mandatoryMessage = *mandatoryMessage;
70 70
  topic->latestMessage = &topic->mandatoryMessage;
71 71
  #if (URT_CFG_PUBSUB_QOS_RATECHECKS)
72
    urt_topic_t.hrtSubscribers = nullptr;
72
    topic->hrtSubscribers = nullptr;
73 73
    //add later: timer init;
74 74
  #endif /* URT_CFG_PUBSUB_QOS_RATECHECKS */
75 75
  #if (URT_CFG_PUBSUB_PROFILING)
76
    urt_topic_t.numMessagesPublished = 0;
77
    urt_topic_t.numMessagesDiscarded = 0;
78
    urt_topic_t.numSubscribers = 0;
76
    topic->numMessagesPublished = 0;
77
    topic->numMessagesDiscarded = 0;
78
    topic->numSubscribers = 0;
79 79
  #endif /* URT_CFG_PUBSUB_PROFILING */
80 80
  topic->latestMessage->next = topic->latestMessage;
81
  urtMutexLock(topic->lock);
81
  urtMutexLock(&topic->lock);
82 82
  urt_topic_t* topicTemp = topic;
83 83
  while (topicTemp != NULL && topicTemp->id < id)
84 84
      topicTemp = topicTemp->next;
85 85

  
86 86
  if (topicTemp == NULL)
87 87
  {
88
    //TODO: Append self to core's list of topic
89
    urtMutexUnlock(topic->lock);
88
    urtCoreAddTopic(topic);
89
    urtMutexUnlock(&topic->lock);
90 90
    return URT_STATUS_OK;
91 91
  }
92 92
  else if (topicTemp->id > id)
93 93
  {
94 94
    topicTemp->next = topic;
95
    urtMutexUnlock(topic->lock);
95
    urtMutexUnlock(&topic->lock);
96 96
    return URT_STATUS_OK;
97 97
  }
98 98
  else
99 99
  {
100
    urtMutexUnlock(topic->lock);
100
    urtMutexUnlock(&topic->lock);
101 101
    return URT_STATUS_TOPIC_DUPLICATE;
102 102
  }
103 103
}

Also available in: Unified diff