Revision 5c6cb22f src/urt_topic.c
src/urt_topic.c | ||
---|---|---|
58 | 58 |
{ |
59 | 59 |
urt_topic_t.next = NULL; |
60 | 60 |
urt_topic_t.id = id; |
61 |
//add later: urtmutexinit, urteventsourceinit |
|
61 |
urtMutexInit(topic->lock); |
|
62 |
urtEventSourceInit(topic->evtSource); |
|
62 | 63 |
urt_topic_t.numHrtSubscribers = 0; |
63 |
//add later: condvar, message init, latest message |
|
64 |
urtCondvarInit(topic->hrtReleased); |
|
65 |
void* payload = NULL; //TODO: Replace |
|
66 |
urtMessageInit(topic->mandatoryMessage, payload); |
|
67 |
topic->latestMessage = &topic->mandatoryMessage; |
|
64 | 68 |
#if (URT_CFG_PUBSUB_QOS_RATECHECKS) |
65 | 69 |
urt_topic_t.hrtSubscribers = nullptr; |
66 | 70 |
//add later: timer init; |
... | ... | |
70 | 74 |
urt_topic_t.numMessagesDiscarded = 0; |
71 | 75 |
urt_topic_t.numSubscribers = 0; |
72 | 76 |
#endif /* URT_CFG_PUBSUB_PROFILING */ |
73 |
//add later: close circular message buffer,... |
|
74 |
return URT_STATUS_OK; |
|
77 |
topic->latestMessage->next = topic->latestMessage; |
|
78 |
urtMutexLock(topic->lock); |
|
79 |
urt_topic_t* topicTemp = topic; |
|
80 |
while (topicTemp != NULL && topicTemp->id < id) |
|
81 |
topicTemp = topicTemp->next; |
|
82 |
|
|
83 |
if (topicTemp == NULL) |
|
84 |
{ |
|
85 |
//TODO: Append self to core's list of topic |
|
86 |
urtMutexUnlock(topic->lock); |
|
87 |
return URT_STATUS_OK; |
|
88 |
} |
|
89 |
else if (topicTemp->id > id) |
|
90 |
{ |
|
91 |
topicTemp->next = topic; |
|
92 |
urtMutexUnlock(topic->lock); |
|
93 |
return URT_STATUS_OK; |
|
94 |
} |
|
95 |
else |
|
96 |
{ |
|
97 |
urtMutexUnlock(topic->lock); |
|
98 |
return URT_STATUS_TOPIC_DUPLICATE; |
|
99 |
} |
|
75 | 100 |
} |
Also available in: Unified diff