MCPcopy Create free account
hub / github.com/cemu-project/Cemu / OSReceiveMessage

Function OSReceiveMessage

src/Cafe/OS/libs/coreinit/coreinit_MessageQueue.cpp:30–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28 }
29
30 bool OSReceiveMessage(OSMessageQueue* msgQueue, OSMessage* msg, uint32 flags)
31 {
32 bool isSystemMessageQueue = (msgQueue == g_systemMessageQueue);
33 if(isSystemMessageQueue)
34 UpdateSystemMessageQueue();
35 __OSLockScheduler(msgQueue);
36 while (msgQueue->usedCount == (uint32be)0)
37 {
38 if ((flags & OS_MESSAGE_BLOCK))
39 {
40 msgQueue->threadQueueReceive.queueAndWait(OSGetCurrentThread());
41 }
42 else
43 {
44 __OSUnlockScheduler(msgQueue);
45 return false;
46 }
47 }
48 // copy message
49 sint32 messageIndex = msgQueue->firstIndex;
50 OSMessage* readMsg = &(msgQueue->msgArray[messageIndex]);
51 memcpy(msg, readMsg, sizeof(OSMessage));
52 msgQueue->firstIndex = ((uint32)msgQueue->firstIndex + 1) % (uint32)(msgQueue->msgCount);
53 msgQueue->usedCount = (uint32)msgQueue->usedCount - 1;
54 // wake up any thread waiting to add a message
55 if (!msgQueue->threadQueueSend.isEmpty())
56 msgQueue->threadQueueSend.wakeupSingleThreadWaitQueue(true);
57 __OSUnlockScheduler(msgQueue);
58 if(isSystemMessageQueue)
59 HandleReceivedSystemMessage(msg);
60 return true;
61 }
62
63 bool OSPeekMessage(OSMessageQueue* msgQueue, OSMessage* msg)
64 {

Callers 5

AXIst_ThreadEntryFunction · 0.85
ProcUIProcessMessagesFunction · 0.85
__FSProcessAsyncResultFunction · 0.85
__IPCDriverThreadFuncFunction · 0.85

Calls 8

UpdateSystemMessageQueueFunction · 0.85
__OSLockSchedulerFunction · 0.85
OSGetCurrentThreadFunction · 0.85
__OSUnlockSchedulerFunction · 0.85
queueAndWaitMethod · 0.80
isEmptyMethod · 0.45

Tested by

no test coverage detected