1 /* 2 * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. 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 * http://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 16 #ifndef TAKS_POOL_FILTER_H 17 #define TAKS_POOL_FILTER_H 18 19 #include <map> 20 #include <string_view> 21 #include <unordered_map> 22 #include "double_map.h" 23 #include "filter_base.h" 24 #include "string_help.h" 25 #include "trace_data_cache.h" 26 #include "trace_streamer_filters.h" 27 28 namespace SysTuning { 29 namespace TraceStreamer { 30 using namespace SysTuning::base; 31 class TaskPoolFilter : private FilterBase { 32 public: 33 TaskPoolFilter(TraceDataCache *dataCache, const TraceStreamerFilters *filter); 34 TaskPoolFilter(const TaskPoolFilter &) = delete; 35 TaskPoolFilter &operator=(const TaskPoolFilter &) = delete; 36 ~TaskPoolFilter() override; 37 uint32_t GetIpId(uint32_t index); 38 uint32_t CheckTheSameTask(uint64_t taskId, uint32_t index); 39 bool TaskPoolEvent(const std::string &taskPoolStr, uint32_t index); 40 void TaskPoolFieldSegmentation(const std::string &taskPoolStr, std::unordered_map<std::string, std::string> &args); 41 bool UpdateAssignData(const std::unordered_map<std::string, std::string> &args, uint32_t index); 42 bool UpdateExecuteData(const std::unordered_map<std::string, std::string> &args, uint32_t index); 43 bool UpdateReturnData(const std::unordered_map<std::string, std::string> &args, uint32_t index); 44 bool AppendTimeoutRow(uint32_t index); 45 46 private: 47 auto GetExecuteIdOrTaskId(const std::unordered_map<std::string, std::string> &args); 48 const std::string targetStr_ = "H:Task"; 49 const std::string allocationStr_ = "H:Task Allocation:"; 50 const std::string executeStr_ = "H:Task Perform:"; 51 const std::string returnStr_ = "H:Task PerformTask End:"; 52 const std::string timeoutStr_ = "H:Thread Timeout Exit"; 53 DoubleMap<InternalPid, uint32_t, uint32_t> IpidExecuteMap_; 54 std::unordered_map<uint32_t, uint32_t> timeoutMap_; 55 }; 56 } // namespace TraceStreamer 57 } // namespace SysTuning 58 #endif // TAKS_POOL_FILTER_H 59