mirror of
https://gitee.com/openharmony/communication_ipc
synced 2024-12-02 13:16:50 +00:00
!1136 【IPC/RPC】BrokerDelegator构造和析构中添加锁保护
Merge pull request !1136 from chenchong_666/master
This commit is contained in:
commit
c2d9edc00e
@ -131,10 +131,12 @@ private:
|
||||
BrokerDelegator(BrokerDelegator &&) = delete;
|
||||
BrokerDelegator &operator = (const BrokerDelegator &) = delete;
|
||||
BrokerDelegator &operator = (BrokerDelegator &&) = delete;
|
||||
std::mutex regMutex_;
|
||||
};
|
||||
|
||||
template <typename T> BrokerDelegator<T>::BrokerDelegator()
|
||||
{
|
||||
std::lock_guard<std::mutex> lockGuard(regMutex_);
|
||||
const std::u16string descriptor = T::GetDescriptor();
|
||||
BrokerRegistration ®istration = BrokerRegistration::Get();
|
||||
if (registration.Register(descriptor, BrokerCreator<T>(), this)) {
|
||||
@ -144,6 +146,7 @@ template <typename T> BrokerDelegator<T>::BrokerDelegator()
|
||||
|
||||
template <typename T> BrokerDelegator<T>::~BrokerDelegator()
|
||||
{
|
||||
std::lock_guard<std::mutex> lockGuard(regMutex_);
|
||||
if (!isSoUnloaded && !descriptor_.empty()) {
|
||||
BrokerRegistration ®istration = BrokerRegistration::Get();
|
||||
registration.Unregister(descriptor_);
|
||||
|
Loading…
Reference in New Issue
Block a user