Skip to content

Commit e75f404

Browse files
committed
Actually allow other threads to access the program mutex
1 parent b5849a2 commit e75f404

File tree

2 files changed

+47
-48
lines changed

2 files changed

+47
-48
lines changed

Diff for: ares/n64/vi/vi.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ auto VI::main() -> void {
117117
io.vcounter = 0;
118118
if(++inactiveCounter >= 200) {
119119
inactiveCounter = 0;
120-
screen->frame();
120+
//screen->frame();
121121
refreshed = true;
122122
}
123123
step(0x800);

Diff for: desktop-ui/program/program.cpp

+46-47
Original file line numberDiff line numberDiff line change
@@ -48,63 +48,62 @@ auto Program::create() -> void {
4848
auto Program::emulatorRunLoop(uintptr_t) -> void {
4949
thread::setName("dev.ares.worker");
5050
while(!_quitting) {
51-
{
52-
lock_guard<recursive_mutex> lock(programMutex);
53-
if(!loaded || !emulator) {
54-
usleep(20 * 1000);
55-
continue;
56-
}
57-
58-
if(emulator && nall::GDB::server.isHalted()) {
59-
ruby::audio.clear();
60-
nall::GDB::server.updateLoop(); // sleeps internally
61-
continue;
62-
}
63-
64-
bool defocused = driverSettings.inputDefocusPause.checked() && !ruby::video.fullScreen() && !presentation.focused();
51+
// Allow other threads to access the program mutex
52+
usleep(1);
53+
54+
lock_guard<recursive_mutex> lock(programMutex);
55+
if(!loaded || !emulator) {
56+
usleep(20 * 1000);
57+
continue;
58+
}
6559

66-
if(!emulator || (paused && !program.requestFrameAdvance) || defocused) {
67-
ruby::audio.clear();
68-
nall::GDB::server.updateLoop();
69-
usleep(20 * 1000);
70-
continue;
71-
}
60+
if(emulator && nall::GDB::server.isHalted()) {
61+
ruby::audio.clear();
62+
nall::GDB::server.updateLoop(); // sleeps internally
63+
continue;
64+
}
7265

73-
rewindRun();
66+
bool defocused = driverSettings.inputDefocusPause.checked() && !ruby::video.fullScreen() && !presentation.focused();
7467

68+
if(!emulator || (paused && !program.requestFrameAdvance) || defocused) {
69+
ruby::audio.clear();
7570
nall::GDB::server.updateLoop();
71+
usleep(20 * 1000);
72+
continue;
73+
}
7674

77-
program.requestFrameAdvance = false;
78-
if(!runAhead || fastForwarding || rewinding) {
79-
emulator->root->run();
80-
} else {
81-
ares::setRunAhead(true);
82-
emulator->root->run();
83-
auto state = emulator->root->serialize(false);
84-
ares::setRunAhead(false);
85-
emulator->root->run();
86-
state.setReading();
87-
emulator->root->unserialize(state);
88-
}
75+
rewindRun();
76+
77+
nall::GDB::server.updateLoop();
78+
79+
program.requestFrameAdvance = false;
80+
if(!runAhead || fastForwarding || rewinding) {
81+
emulator->root->run();
82+
} else {
83+
ares::setRunAhead(true);
84+
emulator->root->run();
85+
auto state = emulator->root->serialize(false);
86+
ares::setRunAhead(false);
87+
emulator->root->run();
88+
state.setReading();
89+
emulator->root->unserialize(state);
90+
}
8991

90-
nall::GDB::server.updateLoop();
92+
nall::GDB::server.updateLoop();
9193

92-
if(settings.general.autoSaveMemory) {
93-
static u64 previousTime = chrono::timestamp();
94-
u64 currentTime = chrono::timestamp();
95-
if(currentTime - previousTime >= 30) {
96-
previousTime = currentTime;
97-
emulator->save();
98-
}
94+
if(settings.general.autoSaveMemory) {
95+
static u64 previousTime = chrono::timestamp();
96+
u64 currentTime = chrono::timestamp();
97+
if(currentTime - previousTime >= 30) {
98+
previousTime = currentTime;
99+
emulator->save();
99100
}
101+
}
100102

101-
if(emulator->latch.changed) {
102-
emulator->latch.changed = false;
103-
_needsResize = true;
104-
}
103+
if(emulator->latch.changed) {
104+
emulator->latch.changed = false;
105+
_needsResize = true;
105106
}
106-
// Allow other threads to access the program mutex
107-
usleep(1);
108107
}
109108
}
110109

0 commit comments

Comments
 (0)