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 #ifndef PANDA_RUNTIME_THREAD_INTERFACE_H 16 #define PANDA_RUNTIME_THREAD_INTERFACE_H 17 18 #include "runtime/include/locks.h" 19 #include "runtime/include/thread_status.h" 20 #include "libpandabase/macros.h" 21 22 namespace ark { 23 24 class PandaVM; 25 26 class ThreadInterface { 27 public: ThreadInterface(MutatorLock * mutatorLock)28 explicit ThreadInterface(MutatorLock *mutatorLock) : mutatorLock_(mutatorLock) {} 29 GetMutatorLock()30 MutatorLock *GetMutatorLock() 31 { 32 return mutatorLock_; 33 } 34 GetMutatorLock()35 const MutatorLock *GetMutatorLock() const 36 { 37 return mutatorLock_; 38 } 39 40 #ifndef NDEBUG GetLockState()41 MutatorLock::MutatorLockState GetLockState() const 42 { 43 return lockState_; 44 } 45 SetLockState(MutatorLock::MutatorLockState state)46 void SetLockState(MutatorLock::MutatorLockState state) 47 { 48 lockState_ = state; 49 } 50 #endif 51 OnRuntimeTerminated()52 virtual void OnRuntimeTerminated() {} 53 PrintSuspensionStackIfNeeded()54 virtual void PrintSuspensionStackIfNeeded() {} 55 GetId()56 virtual uint32_t GetId() const 57 { 58 return 0; 59 } 60 61 private: 62 MutatorLock *mutatorLock_; 63 #ifndef NDEBUG 64 MutatorLock::MutatorLockState lockState_ = MutatorLock::UNLOCKED; 65 #endif 66 }; 67 68 } // namespace ark 69 70 #endif // PANDA_RUNTIME_THREAD_INTERFACE_H 71