SameBoy | Accurate GB/GBC emulator |
| download: https://git.y1.nz/archives/sameboy.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 3168e0e1fabe4a00e96f2b853996a23f9ba9b2af parent 7e6f1f866e89430adaa6be839aecc4a2ccabd69c Author: Lior Halphon <LIJI32@gmail.com> Date: Sat, 12 Aug 2023 13:34:57 +0300 Fixed potential deadlocks Diffstat:
| M | Cocoa/Document.m | 10 | ++++++++-- |
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/Cocoa/Document.m b/Cocoa/Document.m @@ -125,6 +125,7 @@ enum model { void (^ volatile _pendingAtomicBlock)(); NSDate *_fileModificationTime; + __weak NSThread *_emulationThread; } static void boot_rom_load(GB_gameboy_t *gb, GB_boot_rom_t type) @@ -606,7 +607,7 @@ static unsigned *multiplication_table_for_frequency(unsigned frequency) } if (_running) return; _running = true; - [[[NSThread alloc] initWithTarget:self selector:@selector(run) object:nil] start]; + [_emulationThread = [[NSThread alloc] initWithTarget:self selector:@selector(run) object:nil] start]; } - (void) stop @@ -1584,7 +1585,7 @@ static bool is_path_writeable(const char *path) GB_write_memory(&_gb, addr, value); } -- (void) performAtomicBlock: (void (^)())block +- (void)performAtomicBlock: (void (^)())block { while (!GB_is_inited(&_gb)); bool isRunning = _running && !GB_debugger_is_stopped(&_gb); @@ -1601,6 +1602,11 @@ static bool is_path_writeable(const char *path) return; } + if ([NSThread currentThread] == _emulationThread) { + block(); + return; + } + _pendingAtomicBlock = block; while (_pendingAtomicBlock); }
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.