MCPcopy Create free account
hub / github.com/doldecomp/mkdd / callback

Method callback

libs/JSystem/JKernel/JKRThread.cpp:172–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170}
171
172void JKRThreadSwitch::callback(OSThread *current, OSThread *next)
173{
174 if (mUserPreCallback)
175 {
176 (*mUserPreCallback)(current, next);
177 }
178
179 sTotalCount = sTotalCount + 1;
180
181 JKRHeap *next_heap = nullptr;
182 JSUList<JKRThread> &threadList = JKRThread::getList();
183 JSUListIterator<JKRThread> iterator;
184 for (iterator = threadList.getFirst(); iterator != threadList.getEnd(); ++iterator)
185 {
186 JKRThread *thread = iterator.getObject();
187
188 if (thread->getThreadRecord() == current)
189 {
190 thread->setCurrentHeap(JKRHeap::getCurrentHeap());
191 JKRThread::TLoad *loadInfo = thread->getLoadInfo();
192 if (loadInfo->isValid())
193 {
194 loadInfo->addCurrentCost();
195 }
196 }
197
198 if (thread->getThreadRecord() == next)
199 {
200 JKRThread::TLoad *loadInfo = thread->getLoadInfo();
201 if (loadInfo->isValid())
202 {
203 loadInfo->setCurrentTime();
204 loadInfo->incCount();
205 }
206
207 if (sManager->mSetNextHeap)
208 {
209 next_heap = thread->getCurrentHeap();
210 if (!next_heap)
211 {
212 next_heap = JKRHeap::getCurrentHeap();
213 }
214 else if (JKRHeap::getRootHeap()->isSubHeap(next_heap))
215 {
216 continue;
217 }
218 else
219 {
220 switch (thread->getCurrentHeapError())
221 {
222 case 0:
223#line 508
224 JUT_PANIC("JKRThreadSwitch: currentHeap destroyed.");
225 break;
226 case 1:
227 JUTWarningConsole("JKRThreadSwitch: currentHeap destroyed.\n");
228 next_heap = JKRHeap::getCurrentHeap();
229 break;

Callers 1

stateBusyFunction · 0.45

Calls 15

getRootHeapFunction · 0.85
JUTWarningConsoleFunction · 0.85
getSystemHeapFunction · 0.85
getThreadRecordMethod · 0.80
setCurrentHeapMethod · 0.80
getLoadInfoMethod · 0.80
addCurrentCostMethod · 0.80
setCurrentTimeMethod · 0.80
incCountMethod · 0.80
isSubHeapMethod · 0.80
getCurrentHeapErrorMethod · 0.80
becomeCurrentHeapMethod · 0.80

Tested by

no test coverage detected