mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-02-24 15:12:23 +01:00
byuu says: Changes to hiro will break all but the GTK target. Not that it matters much given that the only ruby drivers that function are all on BSD anyway. But if you are fortunate enough to be able to run this ... you'll find lots of polishing improvements to the bsnes GUI. I posted some screenshots on Twitter, if anyone were interested.
55 lines
881 B
C++
55 lines
881 B
C++
#pragma once
|
|
|
|
//shared functionality used for pObject on all platforms
|
|
|
|
struct mLock {
|
|
struct Handle {
|
|
Handle(const mLock* self) : self(self) {
|
|
if(self) {
|
|
++self->locks;
|
|
}
|
|
}
|
|
|
|
~Handle() {
|
|
release();
|
|
}
|
|
|
|
auto release() -> bool {
|
|
if(self) {
|
|
--self->locks;
|
|
self = nullptr;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
const mLock* self = nullptr;
|
|
};
|
|
|
|
auto acquired() const -> bool {
|
|
return locks || Application::state.quit;
|
|
}
|
|
|
|
auto acquire() const -> Handle {
|
|
return {this};
|
|
}
|
|
|
|
//deprecated C-style manual functions
|
|
//prefer RAII acquire() functionality instead in newly written code
|
|
auto locked() const -> bool {
|
|
return acquired();
|
|
}
|
|
|
|
auto lock() -> void {
|
|
++locks;
|
|
}
|
|
|
|
auto unlock() -> void {
|
|
--locks;
|
|
}
|
|
|
|
mutable int locks = 0;
|
|
};
|
|
|
|
using Lock = mLock;
|