mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 14:01:25 +12:00
Emu: Implement BlockingCallFromMainThread
Reduces some copy-paste clutter throughout the project
This commit is contained in:
parent
7842812e24
commit
9cf7a63c77
13 changed files with 95 additions and 223 deletions
|
@ -58,9 +58,9 @@ void headless_application::InitializeCallbacks()
|
|||
|
||||
return false;
|
||||
};
|
||||
callbacks.call_from_main_thread = [this](std::function<void()> func)
|
||||
callbacks.call_from_main_thread = [this](std::function<void()> func, atomic_t<bool>* wake_up)
|
||||
{
|
||||
RequestCallFromMainThread(std::move(func));
|
||||
RequestCallFromMainThread(std::move(func), wake_up);
|
||||
};
|
||||
|
||||
callbacks.init_gs_render = []()
|
||||
|
@ -156,7 +156,13 @@ void headless_application::InitializeCallbacks()
|
|||
/**
|
||||
* Using connects avoids timers being unable to be used in a non-qt thread. So, even if this looks stupid to just call func, it's succinct.
|
||||
*/
|
||||
void headless_application::CallFromMainThread(const std::function<void()>& func)
|
||||
void headless_application::CallFromMainThread(const std::function<void()>& func, atomic_t<bool>* wake_up)
|
||||
{
|
||||
func();
|
||||
|
||||
if (wake_up)
|
||||
{
|
||||
*wake_up = true;
|
||||
wake_up->notify_one();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue