1 /* 2 * Copyright (C) 2024 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 FRAMEWORKS_BASE_COMMONPOOLBASE_H 18 #define FRAMEWORKS_BASE_COMMONPOOLBASE_H 19 20 #include <condition_variable> 21 #include <mutex> 22 #include <vector> 23 24 #include "renderthread/RenderThread.h" 25 26 namespace android { 27 namespace uirenderer { 28 29 class CommonPoolBase { 30 PREVENT_COPY_AND_ASSIGN(CommonPoolBase); 31 32 protected: CommonPoolBase()33 CommonPoolBase() {} 34 setupThread(int i,std::mutex & mLock,std::vector<int> & tids,std::vector<std::condition_variable> & tidConditionVars)35 void setupThread(int i, std::mutex& mLock, std::vector<int>& tids, 36 std::vector<std::condition_variable>& tidConditionVars) { 37 std::array<char, 20> name{"hwuiTask"}; 38 snprintf(name.data(), name.size(), "hwuiTask%d", i); 39 { 40 std::unique_lock lock(mLock); 41 tids[i] = -1; 42 tidConditionVars[i].notify_one(); 43 } 44 auto startHook = renderthread::RenderThread::getOnStartHook(); 45 if (startHook) { 46 startHook(name.data()); 47 } 48 } 49 supportsTid()50 bool supportsTid() { return false; } 51 }; 52 53 } // namespace uirenderer 54 } // namespace android 55 56 #endif // FRAMEWORKS_BASE_COMMONPOOLBASE_H 57