2 * Copyright (C) 2015 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef _MEMORY_REPLAY_THREAD_H
18 #define _MEMORY_REPLAY_THREAD_H
22 #include <sys/types.h>
27 constexpr size_t ACTION_MEMORY_SIZE = 128;
35 void WaitForPending();
39 Action* CreateAction(uintptr_t key_pointer, const char* type, const char* line);
40 void AddTimeNsecs(uint64_t nsecs) { total_time_nsecs_ += nsecs; }
42 void set_pointers(Pointers* pointers) { pointers_ = pointers; }
43 Pointers* pointers() { return pointers_; }
45 Action* GetAction() { return reinterpret_cast<Action*>(action_memory_); }
48 pthread_mutex_t mutex_ = PTHREAD_MUTEX_INITIALIZER;
50 bool pending_ = false;
54 uint64_t total_time_nsecs_ = 0;
56 Pointers* pointers_ = nullptr;
58 // Per thread memory for an Action. Only one action can be processed.
60 static constexpr size_t ACTION_SIZE = 128;
61 uint8_t action_memory_[ACTION_SIZE];
66 #endif // _MEMORY_REPLAY_THREAD_H