Skip to content

Commit

Permalink
[system] remove unique_lock usage as it brings system_error, locales etc
Browse files Browse the repository at this point in the history
  • Loading branch information
avtolstoy committed Jul 20, 2020
1 parent d46db3f commit 9630aa8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
9 changes: 5 additions & 4 deletions system/src/system_cloud_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,11 @@ class CloudConnectionSettings {

CloudDisconnectOptions takePendingDisconnectOptions() {
CloudDisconnectOptions pending;
std::unique_lock<SimpleAtomicFlagMutex> lock(mutex_);
using std::swap;
swap(pending, pendingDisconnectOptions_);
lock.unlock();
{
std::lock_guard<SimpleAtomicFlagMutex> lock(mutex_);
using std::swap;
swap(pending, pendingDisconnectOptions_);
}
CloudDisconnectOptions result;
if (pending.isGracefulSet()) {
result.graceful(pending.graceful());
Expand Down
7 changes: 6 additions & 1 deletion system/src/system_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,11 @@ template<typename Config> void SystemSetupConsole<Config>::loop(void)
}
#endif

TRY_LOCK(serial)
// FIXME: our TRY_LOCK() implementation uses std::unique_lock, which brings
// a lot of unnecessary checks that cause locales and c++ system_error to be
// compiled in. Just call try_lock() for now manually.
// TRY_LOCK(serial)
if (serial.try_lock())
{
if (serial.available())
{
Expand All @@ -234,6 +238,7 @@ template<typename Config> void SystemSetupConsole<Config>::loop(void)
}
}
}
serial.unlock();
}
}

Expand Down

0 comments on commit 9630aa8

Please sign in to comment.