• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 UTILS_INCLUDE_SYNC_FENCE_TRACKER_H
17 #define UTILS_INCLUDE_SYNC_FENCE_TRACKER_H
18 
19 #include <atomic>
20 #include <event_handler.h>
21 #include "sync_fence.h"
22 
23 namespace OHOS {
24 class SyncFenceTracker {
25 public:
26     explicit SyncFenceTracker(const std::string threadName);
27 
28     SyncFenceTracker() = delete;
29     ~SyncFenceTracker() = default;
30 
31     void TrackFence(const sptr<SyncFence>& fence);
32 
33 private:
34     const uint32_t SYNC_TIME_OUT = 3000;
35     const std::string threadName_;
36     std::shared_ptr<OHOS::AppExecFwk::EventRunner> runner_ = nullptr;
37     std::shared_ptr<OHOS::AppExecFwk::EventHandler> handler_ = nullptr;
38     std::atomic<uint32_t> fencesQueued_;
39     std::atomic<uint32_t> fencesSignaled_;
40 
41     void Loop(const sptr<SyncFence>& fence);
42 };
43 }
44 #endif // UTILS_INCLUDE_SYNC_FENCE_TRACKER_H