Merge pull request !9521 from sodanotgreen/wengding
This commit is contained in:
openharmony_ci 2024-07-22 15:24:16 +00:00 committed by Gitee
commit f88067fc46
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 5 additions and 9 deletions

View File

@ -19,18 +19,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_;