Skip to content

Commit

Permalink
Fix user_interface::alloc_thread_bit() usage
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed Sep 10, 2021
1 parent 1cbcf7e commit 1d2a101
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
15 changes: 14 additions & 1 deletion rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,18 @@ namespace rsx
{
if (!exit)
{
g_fxo->get<named_thread<msg_dialog_thread>>()([&, tbit = alloc_thread_bit()]()
auto& dlg_thread = g_fxo->get<named_thread<msg_dialog_thread>>();

const auto notify = std::make_shared<atomic_t<bool>>(false);

dlg_thread([&, notify]()
{
const u64 tbit = alloc_thread_bit();
g_thread_bit = tbit;

*notify = true;
notify->notify_one();

if (interactive)
{
auto ref = g_fxo->get<display_manager>().get(uid);
Expand Down Expand Up @@ -275,6 +283,11 @@ namespace rsx
thread_bits &= ~tbit;
thread_bits.notify_all();
});

while (dlg_thread < thread_state::errored && !*notify)
{
notify->wait(false, atomic_wait_timeout{1'000'000});
}
}
}

Expand Down
15 changes: 14 additions & 1 deletion rpcs3/Emu/RSX/Overlays/overlay_osk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1034,10 +1034,18 @@ namespace rsx

update_panel();

g_fxo->get<named_thread<osk_dialog_thread>>()([this, tbit = alloc_thread_bit()]
auto& osk_thread = g_fxo->get<named_thread<osk_dialog_thread>>();

const auto notify = std::make_shared<atomic_t<bool>>(false);

osk_thread([&, notify]()
{
const u64 tbit = alloc_thread_bit();
g_thread_bit = tbit;

*notify = true;
notify->notify_one();

if (const auto error = run_input_loop())
{
rsx_log.error("Osk input loop exited with error code=%d", error);
Expand All @@ -1046,6 +1054,11 @@ namespace rsx
thread_bits &= ~tbit;
thread_bits.notify_all();
});

while (osk_thread < thread_state::errored && !*notify)
{
notify->wait(false, atomic_wait_timeout{1'000'000});
}
}
}
}
15 changes: 14 additions & 1 deletion rpcs3/Emu/RSX/Overlays/overlay_user_list_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,18 @@ namespace rsx
this->on_close = std::move(on_close);
visible = true;

g_fxo->get<named_thread<user_list_dialog_thread>>()([&, tbit = alloc_thread_bit()]()
auto& list_thread = g_fxo->get<named_thread<user_list_dialog_thread>>();

const auto notify = std::make_shared<atomic_t<bool>>(false);

list_thread([&, notify]()
{
const u64 tbit = alloc_thread_bit();
g_thread_bit = tbit;

*notify = true;
notify->notify_one();

auto ref = g_fxo->get<display_manager>().get(uid);

if (const auto error = run_input_loop())
Expand All @@ -214,6 +222,11 @@ namespace rsx
thread_bits.notify_all();
});

while (list_thread < thread_state::errored && !*notify)
{
notify->wait(false, atomic_wait_timeout{1'000'000});
}

return CELL_OK;
}
} // namespace overlays
Expand Down

0 comments on commit 1d2a101

Please sign in to comment.