Change the naming scheme for class field members

I'm not a fan of Hungarian notation, but C++ kind of needs it with its
implicit `this`. And of all the common options for this, I find
suffixing members with an underscore the least offensive one.
This commit is contained in:
Robbert van der Helm
2022-01-01 21:07:17 +01:00
parent e0ab24e645
commit 0b9a16cf40
169 changed files with 2448 additions and 2405 deletions
+45 -45
View File
@@ -30,22 +30,22 @@ win32_thread_trampoline(fu2::unique_function<void()>* entry_point) {
return 0;
}
Win32Thread::Win32Thread() noexcept : handle(nullptr, nullptr) {}
Win32Thread::Win32Thread() noexcept : handle_(nullptr, nullptr) {}
Win32Thread::~Win32Thread() noexcept {
if (handle) {
WaitForSingleObject(handle.get(), INFINITE);
if (handle_) {
WaitForSingleObject(handle_.get(), INFINITE);
}
}
Win32Thread::Win32Thread(Win32Thread&& o) noexcept
: handle(std::move(o.handle)) {
o.handle.reset();
: handle_(std::move(o.handle_)) {
o.handle_.reset();
}
Win32Thread& Win32Thread::operator=(Win32Thread&& o) noexcept {
handle = std::move(o.handle);
o.handle.reset();
handle_ = std::move(o.handle_);
o.handle_.reset();
return *this;
}
@@ -55,41 +55,41 @@ Win32Timer::Win32Timer() noexcept {}
Win32Timer::Win32Timer(HWND window_handle,
size_t timer_id,
unsigned int interval_ms) noexcept
: window_handle(window_handle), timer_id(timer_id) {
: window_handle_(window_handle), timer_id_(timer_id) {
SetTimer(window_handle, timer_id, interval_ms, nullptr);
}
Win32Timer::~Win32Timer() noexcept {
if (timer_id) {
KillTimer(window_handle, *timer_id);
if (timer_id_) {
KillTimer(window_handle_, *timer_id_);
}
}
Win32Timer::Win32Timer(Win32Timer&& o) noexcept
: window_handle(o.window_handle), timer_id(std::move(o.timer_id)) {
o.timer_id.reset();
: window_handle_(o.window_handle_), timer_id_(std::move(o.timer_id_)) {
o.timer_id_.reset();
}
Win32Timer& Win32Timer::operator=(Win32Timer&& o) noexcept {
window_handle = o.window_handle;
timer_id = std::move(o.timer_id);
o.timer_id.reset();
window_handle_ = o.window_handle_;
timer_id_ = std::move(o.timer_id_);
o.timer_id_.reset();
return *this;
}
MainContext::MainContext()
: context(),
events_timer(context),
watchdog_context(),
watchdog_timer(watchdog_context) {}
: context_(),
events_timer_(context_),
watchdog_context_(),
watchdog_timer_(watchdog_context_) {}
void MainContext::run() {
// We need to know which thread is the GUI thread because mutual recursion
// in VST3 plugins needs to be handled differently depending on whether the
// potentially mutually recursive function was called from an audio thread
// or a GUI thread
gui_thread_id = GetCurrentThreadId();
gui_thread_id_ = GetCurrentThreadId();
// NOTE: We allow disabling the watchdog timer to allow the Wine process to
// be run from a separate namespace. This is not something you'd
@@ -104,62 +104,62 @@ void MainContext::run() {
// this we'll run the timer on a 30 second interval.
async_handle_watchdog_timer(5s);
watchdog_handler = Win32Thread([&]() {
watchdog_handler_ = Win32Thread([&]() {
pthread_setname_np(pthread_self(), "watchdog");
watchdog_context.run();
watchdog_context_.run();
});
}
context.run();
context_.run();
// We only need to check if the host is still running while the main context
// is also running. If a stop was requested, the entire application is
// supposed to shut down. Otherwise `watchdog_handler` would just block on
// the join as the watchdog timer is still active.
watchdog_context.stop();
watchdog_context_.stop();
}
void MainContext::stop() noexcept {
context.stop();
context_.stop();
}
void MainContext::update_timer_interval(
std::chrono::steady_clock::duration new_interval) noexcept {
timer_interval = new_interval;
timer_interval_ = new_interval;
}
MainContext::WatchdogGuard::WatchdogGuard(
HostBridge& bridge,
std::unordered_set<HostBridge*>& watched_bridges,
std::mutex& watched_bridges_mutex)
: bridge(&bridge),
watched_bridges(watched_bridges),
watched_bridges_mutex(watched_bridges_mutex) {
: bridge_(&bridge),
watched_bridges_(watched_bridges),
watched_bridges_mutex_(watched_bridges_mutex) {
std::lock_guard lock(watched_bridges_mutex);
watched_bridges.insert(&bridge);
}
MainContext::WatchdogGuard::~WatchdogGuard() noexcept {
if (is_active) {
std::lock_guard lock(watched_bridges_mutex.get());
watched_bridges.get().erase(bridge);
if (is_active_) {
std::lock_guard lock(watched_bridges_mutex_.get());
watched_bridges_.get().erase(bridge_);
}
}
MainContext::WatchdogGuard::WatchdogGuard(WatchdogGuard&& o) noexcept
: bridge(std::move(o.bridge)),
watched_bridges(std::move(o.watched_bridges)),
watched_bridges_mutex(std::move(o.watched_bridges_mutex)) {
o.is_active = false;
: bridge_(std::move(o.bridge_)),
watched_bridges_(std::move(o.watched_bridges_)),
watched_bridges_mutex_(std::move(o.watched_bridges_mutex_)) {
o.is_active_ = false;
}
MainContext::WatchdogGuard& MainContext::WatchdogGuard::operator=(
WatchdogGuard&& o) noexcept {
bridge = std::move(o.bridge);
watched_bridges = std::move(o.watched_bridges);
watched_bridges_mutex = std::move(o.watched_bridges_mutex);
o.is_active = false;
bridge_ = std::move(o.bridge_);
watched_bridges_ = std::move(o.watched_bridges_);
watched_bridges_mutex_ = std::move(o.watched_bridges_mutex_);
o.is_active_ = false;
return *this;
}
@@ -167,15 +167,15 @@ MainContext::WatchdogGuard& MainContext::WatchdogGuard::operator=(
MainContext::WatchdogGuard MainContext::register_watchdog(HostBridge& bridge) {
// The guard's constructor and destructor will handle actually registering
// and unregistering the bridge from `watched_bridges`
return WatchdogGuard(bridge, watched_bridges, watched_bridges_mutex);
return WatchdogGuard(bridge, watched_bridges_, watched_bridges_mutex_);
}
void MainContext::async_handle_watchdog_timer(
std::chrono::steady_clock::duration interval) {
// Try to keep a steady framerate, but add in delays to let other events
// get handled if the GUI message handling somehow takes very long.
watchdog_timer.expires_at(std::chrono::steady_clock::now() + interval);
watchdog_timer.async_wait([&](const boost::system::error_code& error) {
watchdog_timer_.expires_at(std::chrono::steady_clock::now() + interval);
watchdog_timer_.async_wait([&](const boost::system::error_code& error) {
if (error.failed()) {
return;
}
@@ -184,8 +184,8 @@ void MainContext::async_handle_watchdog_timer(
// bridge instance will be removed from `watched_bridges`. So if our
// call to `HostBridge::shutdown_if_dangling()` shuts the plugin down,
// the instance will be removed after this lambda exits.
std::lock_guard lock(watched_bridges_mutex);
for (auto& bridge : watched_bridges) {
std::lock_guard lock(watched_bridges_mutex_);
for (auto& bridge : watched_bridges_) {
bridge->shutdown_if_dangling();
}