OSDN Git Service

Merge "Support TASKSTATS_TYPE_NULL"
[android-x86/system-extras.git] / memory_replay / Threads.h
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
37   size_t num_threads() { return num_threads_; }
38   size_t max_threads() { return max_threads_; }
39
40  private:
41   Pointers* pointers_ = nullptr;
42   Thread* threads_ = nullptr;
43   size_t data_size_ = 0;
44   size_t max_threads_ = 0;
45   size_t num_threads_= 0;
46
47   Thread* FindEmptyEntry(pid_t tid);
48   size_t GetHashEntry(pid_t tid);
49
50   void ClearData();
51
52   friend Thread;
53 };
54
55 #endif // _MEMORY_REPLAY_THREADS_H