MCPcopy Create free account
hub / github.com/RPCSX/rpcsx / sys_event_queue_destroy

Function sys_event_queue_destroy

kernel/cellos/src/sys_event.cpp:228–345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226}
227
228error_code sys_event_queue_destroy(ppu_thread &ppu, u32 equeue_id, s32 mode) {
229 ppu.state += cpu_flag::wait;
230
231 sys_event.warning("sys_event_queue_destroy(equeue_id=0x%x, mode=%d)",
232 equeue_id, mode);
233
234 if (mode && mode != SYS_EVENT_QUEUE_DESTROY_FORCE) {
235 return CELL_EINVAL;
236 }
237
238 std::vector<lv2_event> events;
239
240 std::unique_lock<shared_mutex> qlock;
241
242 cpu_thread *head{};
243
244 const auto queue = idm::withdraw<lv2_obj, lv2_event_queue>(
245 equeue_id, [&](lv2_event_queue &queue) -> CellError {
246 qlock = std::unique_lock{queue.mutex};
247
248 head = queue.type == SYS_PPU_QUEUE
249 ? static_cast<cpu_thread *>(+queue.pq)
250 : +queue.sq;
251
252 if (!mode && head) {
253 return CELL_EBUSY;
254 }
255
256 if (!queue.events.empty()) {
257 // Copy events for logging, does not empty
258 events.insert(events.begin(), queue.events.begin(),
259 queue.events.end());
260 }
261
262 lv2_obj::on_id_destroy(queue, queue.key);
263
264 if (!head) {
265 qlock.unlock();
266 } else {
267 for (auto cpu = head; cpu; cpu = cpu->get_next_cpu()) {
268 if (cpu->state & cpu_flag::again) {
269 ppu.state += cpu_flag::again;
270 return CELL_EAGAIN;
271 }
272 }
273 }
274
275 return {};
276 });
277
278 if (!queue) {
279 return CELL_ESRCH;
280 }
281
282 if (ppu.state & cpu_flag::again) {
283 return {};
284 }
285

Callers 7

sys_config_stopFunction · 0.85
create_lv2_eqMethod · 0.85
create_event_helperMethod · 0.85
stop_event_helperMethod · 0.85
sys_rsx_context_freeFunction · 0.85

Calls 12

appendFunction · 0.85
get_next_cpuMethod · 0.80
set_valuesMethod · 0.80
emptyMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
unlockMethod · 0.45
get_nameMethod · 0.45
appendMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected