MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / WaitForEmpty

Method WaitForEmpty

common/Semaphore.cpp:94–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94bool Threading::WorkSema::WaitForEmpty()
95{
96 s32 value = m_state.load(std::memory_order_acquire);
97 while (true)
98 {
99 if (value < 0)
100 return !IsDead(value); // STATE_SLEEPING or STATE_SPINNING, queue is empty!
101 // Note: We technically only need memory_order_acquire on *failure* (because that's when we could leave without sleeping), but libstdc++ still asserts on failure < success
102 if (m_state.compare_exchange_weak(value, value | STATE_FLAG_WAITING_EMPTY, std::memory_order_acquire))
103 break;
104 }
105 pxAssertMsg(!(value & STATE_FLAG_WAITING_EMPTY), "Multiple threads attempted to wait for empty (not currently supported)");
106 m_empty_sema.Wait();
107 return !IsDead(m_state.load(std::memory_order_relaxed));
108}
109
110bool Threading::WorkSema::WaitForEmptyWithSpin()
111{

Callers 2

WaitGSMethod · 0.80
WaitVUMethod · 0.80

Calls 2

loadMethod · 0.45
WaitMethod · 0.45

Tested by

no test coverage detected