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

Function IOS_ReceiveMessage

src/Cafe/IOSU/kernel/iosu_kernel.cpp:135–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133 }
134
135 IOS_ERROR IOS_ReceiveMessage(IOSMsgQueueId msgQueueId, IOSMessage* messageOut, uint32 flags)
136 {
137 std::unique_lock _l(sInternalMutex);
138 cemu_assert_debug(flags == 0 || flags == 1);
139 bool dontBlock = (flags & 1) != 0;
140 IOSMessageQueue* msgQueue = nullptr;
141 IOS_ERROR r = _IOS_GetMessageQueue(msgQueueId, msgQueue);
142 if (r != IOS_ERROR_OK)
143 return r;
144 while (true)
145 {
146 if (msgQueue->numQueuedMessages == 0)
147 {
148 if (dontBlock)
149 return IOS_ERROR_NONE_AVAILABLE;
150 }
151 else
152 break;
153 msgQueue->cv_recv.wait(_l);
154 // after returning from wait, make sure the queue handle is unchanged
155 if (msgQueue->queueHandle != msgQueueId)
156 return IOS_ERROR_INVALID;
157 }
158 *messageOut = msgQueue->msgArray[(uint32)msgQueue->readIndex];
159 msgQueue->readIndex = msgQueue->readIndex + 1;
160 if (msgQueue->readIndex >= msgQueue->msgArraySize)
161 msgQueue->readIndex -= msgQueue->msgArraySize;
162 msgQueue->numQueuedMessages -= 1;
163 msgQueue->cv_send.notify_one();
164 return IOS_ERROR_OK;
165 }
166
167 /* timer */
168

Callers 5

MCPIoThreadFunction · 0.85
CCRNFCThreadFunction · 0.85
FSAIoThreadFunction · 0.85
ODMServiceThreadFunction · 0.85
ServiceThreadMethod · 0.85

Calls 3

cemu_assert_debugFunction · 0.85
_IOS_GetMessageQueueFunction · 0.85
waitMethod · 0.80

Tested by

no test coverage detected