• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_PROXY_HYBRID_H
16 #define PANDA_RUNTIME_THREAD_PROXY_HYBRID_H
17 
18 #ifdef ARK_HYBRID
19 
20 #include "runtime/include/thread_interface.h"
21 
22 #include "thread/base_thread.h"
23 
24 namespace ark {
25 
26 class ThreadProxyHybrid : public ThreadInterface {
27 public:
ThreadProxyHybrid(MutatorLock * mutatorLock)28     explicit ThreadProxyHybrid(MutatorLock *mutatorLock) : ThreadInterface(mutatorLock) {}
29 
30     bool TestAllFlags() const;
31 
32     enum ThreadStatus GetStatus() const;
33 
34     void InitializeThreadFlag();
35 
36     void UpdateStatus(enum ThreadStatus status) NO_THREAD_SAFETY_ANALYSIS;
37 
38     bool IsSuspended() const;
39 
40     bool IsRuntimeTerminated() const;
41 
42     void SetRuntimeTerminated();
43 
44     void SuspendCheck();
45 
46     void SuspendImpl(bool internalSuspend = false);
47 
48     void ResumeImpl(bool internalResume = false);
49 
50     void SafepointPoll();
51 
52     bool IsUserSuspended();
53 
54     void WaitSuspension();
55 
56     void MakeTSANHappyForThreadState();
57 
58     void CleanUpThreadStatus();
59 
GetFlagOffset()60     static constexpr uint32_t GetFlagOffset()
61     {
62         return 0;
63     };
64 
InitializeInitThreadFlag()65     static void InitializeInitThreadFlag() {};
66 
67     /// @returns true if holder was created
68     bool CreateExternalHolderIfNeeded(bool useSharedHolder);
69 
GetThreadHolder()70     panda::ThreadHolder *GetThreadHolder() const
71     {
72         ASSERT(threadHolder_ != nullptr);
73         return threadHolder_;
74     }
75 
76 private:
77     panda::ThreadHolder *threadHolder_ = nullptr;
78 };
79 
80 }  // namespace ark
81 
82 #endif
83 
84 #endif  // PANDA_RUNTIME_THREAD_PROXY_HYBRID_H
85