fix nano sleep

Signed-off-by: woohoa <wanghuan36@huawei.com>
This commit is contained in:
15950533375
2024-12-11 15:58:32 +08:00
parent f2b4982b10
commit 2e6df03d69
2 changed files with 26 additions and 15 deletions
@@ -33,7 +33,7 @@ const int32_t DB_DOMAIN_INDEX = 3;
const int32_t DB_STATUES_INDEX = 4;
const int32_t DB_VERIFY_TIME_INDEX = 5;
const int32_t DB_VERIFY_COUNT_INDEX = 6;
const int32_t CLOSE_TIME = 20; // delay 20s stop rdbStore
const int32_t CLOSE_TIME = 20 * 1000; // delay 20s stop rdbStore
AppDomainVerifyRdbDataManager::AppDomainVerifyRdbDataManager(const AppDomainVerifyRdbConfig& rdbConfig)
: appDomainVerifyRdbConfig_(rdbConfig)
@@ -206,7 +206,6 @@ void AppDomainVerifyRdbDataManager::DelayCloseRdbStore()
std::weak_ptr<AppDomainVerifyRdbDataManager> weakPtr = shared_from_this();
auto func = [weakPtr]() {
APP_DOMAIN_VERIFY_HILOGD(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "DelayCloseRdbStore thread begin");
std::this_thread::sleep_for(std::chrono::seconds(CLOSE_TIME));
auto sharedPtr = weakPtr.lock();
if (sharedPtr == nullptr) {
return;
@@ -215,7 +214,7 @@ void AppDomainVerifyRdbDataManager::DelayCloseRdbStore()
sharedPtr->rdbStore_ = nullptr;
APP_DOMAIN_VERIFY_HILOGD(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "DelayCloseRdbStore thread end");
};
continuationHandler_->submit(func);
continuationHandler_->submit(func, ffrt::task_attr().delay(CLOSE_TIME));
APP_DOMAIN_VERIFY_HILOGD(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "call end");
}
+24 -12
View File
@@ -1,28 +1,40 @@
/*
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FFRT_API_FFRT_H
#define FFRT_API_FFRT_H
#include <functional>
namespace ffrt {
class task_attr {
public:
task_attr() = default;
inline task_attr& delay(uint64_t delay_us)
{
return *this;
}
};
class queue {
public:
queue(std::string name){};
inline void submit(const std::function<void()>& func)
{
}
inline void submit(const std::function<void()>& func, const task_attr& attr)
{
}
};
}