/* * Copyright (c) 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. */ #include #include #include #include #include "distributed_file_daemon_manager.h" #include "pasteboard_error.h" #include "pasteboard_hilog.h" #include "pasteboard_progress_signal.h" namespace OHOS { namespace MiscServices { std::mutex ProgressSignalClient::mutex_; ProgressSignalClient *ProgressSignalClient::instance_ = nullptr; ProgressSignalClient &ProgressSignalClient::GetInstance() { if (instance_ == nullptr) { std::lock_guard lock(mutex_); instance_ = new ProgressSignalClient(); } return *instance_; } void ProgressSignalClient::Init() { instance_ = nullptr; needCancel_.store(false); remoteTask_.store(false); } void ProgressSignalClient::Cancel() { PASTEBOARD_HILOGD(PASTEBOARD_MODULE_CLIENT, "ProgressSignalClient Cancel in!"); needCancel_.store(true); } bool ProgressSignalClient::IsCanceled() { return needCancel_.load() || remoteTask_.load(); } bool ProgressSignalClient::CheckCancelIfNeed() { if (!needCancel_.load()) { return false; } return true; } void ProgressSignalClient::SetRemoteTaskCancel() { needCancel_.store(true); } } // namespace MiscServices } // namespace OHOS