Concurrency management of multiple topics

3 posts / 0 new
Last post
Offline
Last seen: 4 years 1 week ago
Joined: 09/14/2016
Posts: 2
Concurrency management of multiple topics

Hello,

I have multiple writers publishing multiple topics which are dependent each other. The samples of the topics must be synched. When one writer publishes the samples of the topics, other writers must wait until all published samples are delivered to the subscribers. It is similar to mutex or semaphore for C/C++. Is there anyway to make this work without implementing application side behaviors? Using QOS profile? Thanks.

asanchez's picture
Offline
Last seen: 3 months 3 weeks ago
Joined: 11/16/2011
Posts: 50

Hi,


Not sure exactly of the semantics of your application and what "delievered to the subscriber" implies, but one possiblity you could consider is to call wait_for_ackwnoledgements() after each write operation. If you are writing all topics from the same thread, then this is straightforward.

-Antonio

Offline
Last seen: 4 years 1 week ago
Joined: 09/14/2016
Posts: 2

An example of my problem is as follows. Two topics are defined as,

t1 {
string id; //@key
int t2_count;
}

t2 {
string id;//@key
string t1_ref_id;
}

a datawriter publishes both topics with t2.t1_ref_id=t1.id, t1.t2_count=1. Then the datawriter publishes them again with different t2.id and set t1.t2_count=2 and so on. while it is happening, the other datawriter publishes the same topics in the same way. If the first datawriter publishes t1 and before it publishes t2 the second datawriter publishes t1, then the data integrities of t1 and t2 are broken. So is there any way to preserve the data integrity in this case? In the multi-threaded programming, a mutex or a semaphore is used for these kind of issues.