BewareMyPower opened a new pull request #14380:
URL: https://github.com/apache/pulsar/pull/14380
**Motivation**
In C++ client, if a consumer subscribes multiple topics, a
`MultiTopicsConsumerImpl` object, which manages a vector of
`ConsumerImpl`s (`consumers_` field), will be created. However,
`consumers_` could be accessed by multiple threads, while no
mutex is locked to protect the access to make it thread safe.
**Modifications**
- Add a `SynchronizedHashMap` class, which implements some thread safe
methods of traverse, remove, find, clear operations. Since the
`forEach` methods could call other methods, use the recursive mutex
instead of the default mutex.
- Add a related test `SynchronizedHashMapTest` to test the methods and
the thread safety of `SynchronizedHashMap`.
- Use `SynchronizedHashMap` as the type of
`MultiTopicsConsumerImpl::consumers_`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]