Shaka Player Embedded
waiting_tracker.h
Go to the documentation of this file.
1 // Copyright 2018 Google LLC
2 //
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 // https://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 #ifndef SHAKA_EMBEDDED_DEBUG_WAITING_TRACKER_H_
16 #define SHAKA_EMBEDDED_DEBUG_WAITING_TRACKER_H_
17 
18 namespace shaka {
19 
20 class Thread;
21 class Waitable;
22 
29  public:
30 #ifdef DEBUG_DEADLOCKS
31  struct TrackerScope {
32  TrackerScope(const TrackerScope&) = delete;
33  TrackerScope(TrackerScope&&);
34  ~TrackerScope();
35 
36  TrackerScope& operator=(const TrackerScope&) = delete;
37  TrackerScope& operator=(TrackerScope&&);
38 
39  private:
40  friend WaitingTracker;
41  TrackerScope();
42  bool exec_;
43  };
44 
45  static void AddThread(const Thread* thread);
46  static void RemoveThread(const Thread* thread);
47  static void RemoveWaitable(const Waitable* waiting_on);
48 
53  static void ThreadExit();
54 
60  static void UpdateProvider(const Waitable* waiting_on);
61 
67  static TrackerScope ThreadWaiting(const Waitable* waiting_on);
68 #endif
69 
70  private:
71  WaitingTracker() {}
72 };
73 
74 } // namespace shaka
75 
76 #endif // SHAKA_EMBEDDED_DEBUG_WAITING_TRACKER_H_