• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef PASTEBOARD_PROGRESS_SIGNAL_H
17 #define PASTEBOARD_PROGRESS_SIGNAL_H
18 
19 #include <condition_variable>
20 #include <memory>
21 #include <functional>
22 #include <singleton.h>
23 #include <string>
24 #include <unistd.h>
25 #include "visibility.h"
26 
27 namespace OHOS {
28 namespace MiscServices {
29 class API_EXPORT ProgressSignalClient {
30 public:
31     static ProgressSignalClient &GetInstance();
32     void Cancel();
33     bool IsCanceled();
34     bool CheckCancelIfNeed();
35     void Init();
36     void SetRemoteTaskCancel();
37 
38 private:
39     ProgressSignalClient() = default;
40     ~ProgressSignalClient() = default;
41     DISALLOW_COPY_AND_MOVE(ProgressSignalClient);
42     std::atomic_bool needCancel_{ false };
43     std::atomic_bool remoteTask_{ false };
44     static std::mutex mutex_;
45     static ProgressSignalClient *instance_;
46 };
47 } // namespace MiscServices
48 } // namespace OHOS
49 #endif // PASTEBOARD_PROGRESS_SIGNAL_H