1 /* 2 * Copyright (c) 2025 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 COMMON_INTERFACES_THREAD_BASE_THREAD_H 17 #define COMMON_INTERFACES_THREAD_BASE_THREAD_H 18 19 #include "thread/thread_holder-inl.h" 20 21 #include "base/common.h" 22 23 namespace common { 24 // Fixme: replace with real RootVisitor 25 using MockRootVisitor = void (*)(); 26 27 enum class BaseThreadType { 28 JS_THREAD, 29 STS_THREAD, 30 }; 31 32 /** 33 * BaseThread is the abstract base class for different languages 34 */ 35 class BaseThread { 36 public: BaseThread(BaseThreadType type,ThreadHolder * holder)37 explicit BaseThread(BaseThreadType type, ThreadHolder *holder) : threadType_(type), threadHolder_(holder) {} 38 virtual ~BaseThread() = default; 39 40 NO_COPY_SEMANTIC_CC(BaseThread); 41 NO_MOVE_SEMANTIC_CC(BaseThread); 42 GetThreadType()43 BaseThreadType GetThreadType() const 44 { 45 return threadType_; 46 } 47 GetThreadHolder()48 ThreadHolder *GetThreadHolder() const 49 { 50 return threadHolder_; 51 } 52 53 private: 54 BaseThreadType threadType_ {}; 55 ThreadHolder *threadHolder_ {}; 56 }; 57 } // namespace common 58 #endif // COMMON_INTERFACES_THREAD_BASE_THREAD_H