1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 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 DFX_FAULTS_MULTI_THREAD_CONTAINER_ACCESS_H 17 #define DFX_FAULTS_MULTI_THREAD_CONTAINER_ACCESS_H 18 19 #include <cinttypes> 20 #include <cstdlib> 21 #include <list> 22 #include <map> 23 #include <string> 24 #include <vector> 25 26 int MultiThreadVectorAccess(); 27 int MultiThreadMapAccess(void); 28 int MultiThreadListAccess(void); 29 30 namespace OHOS { 31 namespace HiviewDFX { 32 class MultiThreadContainerAccess { 33 public: MultiThreadContainerAccess()34 MultiThreadContainerAccess() {}; ~MultiThreadContainerAccess()35 ~MultiThreadContainerAccess() {}; 36 37 void ManipulateVector(); 38 void ManipulateMap(); 39 void ManipulateList(); 40 void Print() const; 41 42 private: 43 static constexpr int MANIPULATION_TYPE = 2; 44 static constexpr int ADD = 0; 45 static constexpr int REMOVE = 1; 46 static std::string GenerateStr(); 47 48 private: 49 std::vector<std::string> strVector_; 50 std::map<int, std::string> strMap_; 51 std::list<std::string> strList_; 52 }; 53 } // namespace HiviewDFX 54 } // namespace OHOS 55 #endif 56