Skip to content

Commit

Permalink
sys_event_flag improved
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekotekina committed Jul 21, 2015
1 parent bc91ad0 commit 6255f3b
Show file tree
Hide file tree
Showing 7 changed files with 211 additions and 196 deletions.
32 changes: 12 additions & 20 deletions rpcs3/Emu/Cell/SPUThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -951,23 +951,19 @@ void SPUThread::set_ch_value(u32 ch, u32 value)
LOG_WARNING(SPU, "sys_event_flag_set_bit(id=%d, value=0x%x (flag=%d))", data, value, flag);
}

const auto ef = Emu.GetIdManager().get<lv2_event_flag_t>(data);
const auto eflag = Emu.GetIdManager().get<lv2_event_flag_t>(data);

if (!ef)
if (!eflag)
{
return ch_in_mbox.set_values(1, CELL_ESRCH);
}

while (ef->cancelled)
{
ef->cv.wait_for(lv2_lock, std::chrono::milliseconds(1));
}

ef->flags |= 1ull << flag;
const u64 bitptn = 1ull << flag;

if (ef->waiters)
if (~eflag->pattern.fetch_or(bitptn) & bitptn)
{
ef->cv.notify_all();
// notify if the bit was set
eflag->notify_all(lv2_lock);
}

return ch_in_mbox.set_values(1, CELL_OK);
Expand Down Expand Up @@ -999,23 +995,19 @@ void SPUThread::set_ch_value(u32 ch, u32 value)
LOG_WARNING(SPU, "sys_event_flag_set_bit_impatient(id=%d, value=0x%x (flag=%d))", data, value, flag);
}

const auto ef = Emu.GetIdManager().get<lv2_event_flag_t>(data);
const auto eflag = Emu.GetIdManager().get<lv2_event_flag_t>(data);

if (!ef)
if (!eflag)
{
return;
}

while (ef->cancelled)
{
ef->cv.wait_for(lv2_lock, std::chrono::milliseconds(1));
}

ef->flags |= 1ull << flag;
const u64 bitptn = 1ull << flag;

if (ef->waiters)
if (~eflag->pattern.fetch_or(bitptn) & bitptn)
{
ef->cv.notify_all();
// notify if the bit was set
eflag->notify_all(lv2_lock);
}

return;
Expand Down
13 changes: 0 additions & 13 deletions rpcs3/Emu/Event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,6 @@ void EventManager::Clear()
m_map.clear();
}

bool EventManager::CheckKey(u64 key)
{
if (!key)
{
// never exists
return false;
}

std::lock_guard<std::mutex> lock(m_mutex);

return m_map.find(key) != m_map.end();
}

bool EventManager::UnregisterKey(u64 key)
{
if (!key)
Expand Down
1 change: 0 additions & 1 deletion rpcs3/Emu/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class EventManager
public:
void Init();
void Clear();
bool CheckKey(u64 key);
bool UnregisterKey(u64 key);

template<typename... Args, typename = std::enable_if_t<std::is_constructible<lv2_event_queue_t, Args...>::value>> std::shared_ptr<lv2_event_queue_t> MakeEventQueue(u64 key, Args&&... args)
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/SysCalls/lv2/sys_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ enum : s32
// Event Queue Ipc Key
enum : u64
{
SYS_EVENT_QUEUE_LOCAL = 0x00,
SYS_EVENT_QUEUE_LOCAL = 0,
};

// Event Port Type
Expand Down
Loading

0 comments on commit 6255f3b

Please sign in to comment.