Signed-off-by: sodanotgreen <limengzheng@huawei.com>
This commit is contained in:
sodanotgreen 2024-07-21 15:56:49 +08:00
parent f5be29f135
commit 979d295613
2 changed files with 5 additions and 9 deletions

View File

@ -20,18 +20,13 @@ namespace OHOS {
namespace AbilityRuntime {
sptr<InsightIntentHostClient> InsightIntentHostClient::instance_ = nullptr;
std::mutex InsightIntentHostClient::instanceMutex_;
std::once_flag InsightIntentHostClient::singletonFlag_;
sptr<InsightIntentHostClient> InsightIntentHostClient::GetInstance()
{
if (instance_ == nullptr) {
std::lock_guard<std::mutex> lock_l(instanceMutex_);
if (instance_ == nullptr) {
instance_ = new (std::nothrow) InsightIntentHostClient();
if (instance_ == nullptr) {
TAG_LOGE(AAFwkTag::INTENT, "failed to create InsightIntentHostClient.");
}
}
}
std::call_once(singletonFlag_, []() {
instance_ = new (std::nothrow) InsightIntentHostClient();
})
return instance_;
}

View File

@ -59,6 +59,7 @@ public:
private:
static std::mutex instanceMutex_;
static std::once_flag singletonFlag_;
uint64_t key_ = 0;
static sptr<InsightIntentHostClient> instance_;
mutable std::mutex insightIntentExecutebackMutex_;