... | ... | @@ -198,7 +198,7 @@ catch (InitException e) { |
|
|
```
|
|
|
|
|
|
Here again, *This* must have been initialized before creating the publisher. We provide a synchronization feature with the second argument of the *Publisher.create()* method: the number of subscribers can be provided. The call to *Publisher.init()* is blocking until the required number of subscribers has been reached. This allows to have subscribers that will receive all the messages: The publisher is **synchronized**.
|
|
|
Default value is 0 and in that case *Publisher.init()* immediately returns. Then the publisher is **not** synchronized and some messages may be lost. There is another option for the publisher: synchronized subscribers. It is set using *setSyncSubscribers()* instead of *setWaitForSubscribers()* so that the publisher is not waiting for the subscribers but the subscribers are effectively connected at the end of their *init()*.
|
|
|
Default value is 0 and in that case *Publisher.init()* immediately returns. Then the publisher is **not** synchronized and some messages may be lost. There is another option for the publisher: synchronized subscribers. It is set using *setSyncSubscribers()* instead of *setWaitForSubscribers()* so that the publisher is not waiting for the subscribers but the subscribers are effectively connected at the end of their *init()*. The implementation requires an additional thread that is why it is not set by default.
|
|
|
|
|
|
Let's give an example of a subscriber in C++:
|
|
|
```cpp
|
... | ... | |