• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_AUTOMOTIVE_COMPUTEPIPE_ROUTER_V1_0_REMOTESTATE
18 #define ANDROID_AUTOMOTIVE_COMPUTEPIPE_ROUTER_V1_0_REMOTESTATE
19 
20 #include <utils/RefBase.h>
21 
22 #include <memory>
23 #include <mutex>
24 
25 namespace android {
26 namespace automotive {
27 namespace computepipe {
28 namespace router {
29 namespace V1_0 {
30 namespace implementation {
31 
32 /**
33  * Wrapper for the Runner State machine
34  */
35 class RemoteState {
36   public:
37     RemoteState() = default;
38     void markDead();
39     bool isAlive();
40 
41   private:
42     std::mutex mStateLock;
43     bool mAlive = true;
44 };
45 
46 /**
47  * Monitor for tracking remote state
48  */
49 class RemoteMonitor : public RefBase {
50   public:
RemoteMonitor(const std::weak_ptr<RemoteState> & s)51     explicit RemoteMonitor(const std::weak_ptr<RemoteState>& s) : mState(s) {
52     }
53     static void BinderDiedCallback(void* cookie);
54     void binderDied();
55 
56   private:
57     std::weak_ptr<RemoteState> mState;
58 };
59 
60 }  // namespace implementation
61 }  // namespace V1_0
62 }  // namespace router
63 }  // namespace computepipe
64 }  // namespace automotive
65 }  // namespace android
66 #endif
67