mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-15 04:00:07 +00:00
Merge pull request #11546 from Kelebek1/core_timing_mutex
Reduce core timing mutex contention
This commit is contained in:
commit
d6b3e7f195
@ -542,6 +542,7 @@ void EmulatedController::UnloadInput() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EmulatedController::EnableConfiguration() {
|
void EmulatedController::EnableConfiguration() {
|
||||||
|
std::scoped_lock lock{connect_mutex, npad_mutex};
|
||||||
is_configuring = true;
|
is_configuring = true;
|
||||||
tmp_is_connected = is_connected;
|
tmp_is_connected = is_connected;
|
||||||
tmp_npad_type = npad_type;
|
tmp_npad_type = npad_type;
|
||||||
@ -1556,7 +1557,7 @@ void EmulatedController::Connect(bool use_temporary_value) {
|
|||||||
|
|
||||||
auto trigger_guard =
|
auto trigger_guard =
|
||||||
SCOPE_GUARD({ TriggerOnChange(ControllerTriggerType::Connected, !is_configuring); });
|
SCOPE_GUARD({ TriggerOnChange(ControllerTriggerType::Connected, !is_configuring); });
|
||||||
std::scoped_lock lock{mutex};
|
std::scoped_lock lock{connect_mutex, mutex};
|
||||||
if (is_configuring) {
|
if (is_configuring) {
|
||||||
tmp_is_connected = true;
|
tmp_is_connected = true;
|
||||||
return;
|
return;
|
||||||
@ -1572,7 +1573,7 @@ void EmulatedController::Connect(bool use_temporary_value) {
|
|||||||
void EmulatedController::Disconnect() {
|
void EmulatedController::Disconnect() {
|
||||||
auto trigger_guard =
|
auto trigger_guard =
|
||||||
SCOPE_GUARD({ TriggerOnChange(ControllerTriggerType::Disconnected, !is_configuring); });
|
SCOPE_GUARD({ TriggerOnChange(ControllerTriggerType::Disconnected, !is_configuring); });
|
||||||
std::scoped_lock lock{mutex};
|
std::scoped_lock lock{connect_mutex, mutex};
|
||||||
if (is_configuring) {
|
if (is_configuring) {
|
||||||
tmp_is_connected = false;
|
tmp_is_connected = false;
|
||||||
return;
|
return;
|
||||||
@ -1586,7 +1587,7 @@ void EmulatedController::Disconnect() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool EmulatedController::IsConnected(bool get_temporary_value) const {
|
bool EmulatedController::IsConnected(bool get_temporary_value) const {
|
||||||
std::scoped_lock lock{mutex};
|
std::scoped_lock lock{connect_mutex};
|
||||||
if (get_temporary_value && is_configuring) {
|
if (get_temporary_value && is_configuring) {
|
||||||
return tmp_is_connected;
|
return tmp_is_connected;
|
||||||
}
|
}
|
||||||
@ -1599,7 +1600,7 @@ NpadIdType EmulatedController::GetNpadIdType() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NpadStyleIndex EmulatedController::GetNpadStyleIndex(bool get_temporary_value) const {
|
NpadStyleIndex EmulatedController::GetNpadStyleIndex(bool get_temporary_value) const {
|
||||||
std::scoped_lock lock{mutex};
|
std::scoped_lock lock{npad_mutex};
|
||||||
if (get_temporary_value && is_configuring) {
|
if (get_temporary_value && is_configuring) {
|
||||||
return tmp_npad_type;
|
return tmp_npad_type;
|
||||||
}
|
}
|
||||||
@ -1609,7 +1610,7 @@ NpadStyleIndex EmulatedController::GetNpadStyleIndex(bool get_temporary_value) c
|
|||||||
void EmulatedController::SetNpadStyleIndex(NpadStyleIndex npad_type_) {
|
void EmulatedController::SetNpadStyleIndex(NpadStyleIndex npad_type_) {
|
||||||
auto trigger_guard =
|
auto trigger_guard =
|
||||||
SCOPE_GUARD({ TriggerOnChange(ControllerTriggerType::Type, !is_configuring); });
|
SCOPE_GUARD({ TriggerOnChange(ControllerTriggerType::Type, !is_configuring); });
|
||||||
std::scoped_lock lock{mutex};
|
std::scoped_lock lock{mutex, npad_mutex};
|
||||||
|
|
||||||
if (is_configuring) {
|
if (is_configuring) {
|
||||||
if (tmp_npad_type == npad_type_) {
|
if (tmp_npad_type == npad_type_) {
|
||||||
|
@ -603,6 +603,8 @@ private:
|
|||||||
|
|
||||||
mutable std::mutex mutex;
|
mutable std::mutex mutex;
|
||||||
mutable std::mutex callback_mutex;
|
mutable std::mutex callback_mutex;
|
||||||
|
mutable std::mutex npad_mutex;
|
||||||
|
mutable std::mutex connect_mutex;
|
||||||
std::unordered_map<int, ControllerUpdateCallback> callback_list;
|
std::unordered_map<int, ControllerUpdateCallback> callback_list;
|
||||||
int last_callback_key = 0;
|
int last_callback_key = 0;
|
||||||
|
|
||||||
|
@ -35,7 +35,9 @@ void KHardwareTimer::DoTask() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Disable the timer interrupt while we handle this.
|
// Disable the timer interrupt while we handle this.
|
||||||
this->DisableInterrupt();
|
// Not necessary due to core timing already having popped this event to call it.
|
||||||
|
// this->DisableInterrupt();
|
||||||
|
m_wakeup_time = std::numeric_limits<s64>::max();
|
||||||
|
|
||||||
if (const s64 next_time = this->DoInterruptTaskImpl(GetTick());
|
if (const s64 next_time = this->DoInterruptTaskImpl(GetTick());
|
||||||
0 < next_time && next_time <= m_wakeup_time) {
|
0 < next_time && next_time <= m_wakeup_time) {
|
||||||
|
Loading…
Reference in New Issue
Block a user