• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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 _MEMORY_REPLAY_THREADS_H
18 #define _MEMORY_REPLAY_THREADS_H
19 
20 #include <stdint.h>
21 #include <sys/types.h>
22 
23 class Pointers;
24 class Thread;
25 
26 class Threads {
27  public:
28   Threads(Pointers* pointers, size_t max_threads);
29   virtual ~Threads();
30 
31   Thread* CreateThread(pid_t tid);
32   Thread* FindThread(pid_t tid);
33   void WaitForAllToQuiesce();
34   void Finish(Thread* thread);
35   void FinishAll();
36 
num_threads()37   size_t num_threads() { return num_threads_; }
max_threads()38   size_t max_threads() { return max_threads_; }
total_time_nsecs()39   uint64_t total_time_nsecs() { return total_time_nsecs_; }
40 
41  private:
42   Pointers* pointers_ = nullptr;
43   Thread* threads_ = nullptr;
44   size_t data_size_ = 0;
45   size_t max_threads_ = 0;
46   size_t num_threads_= 0;
47   uint64_t total_time_nsecs_ = 0;
48 
49   Thread* FindEmptyEntry(pid_t tid);
50   size_t GetHashEntry(pid_t tid);
51 
52   void ClearData();
53 
54   friend Thread;
55 };
56 
57 #endif // _MEMORY_REPLAY_THREADS_H
58