Introduce fish_mutex_t wrapping std::mutex

Add a fish-specific wrapper around std::mutex that records whether it is
locked in a bool. This is to make ASSERT_IS_LOCKED() simpler (it can just
check the boolean instead of relying on try_lock) which will make Coverity
Scan happier.

Some details: Coverity Scan was complaining about an apparent double-unlock
because it's unaware of the semantics of try_lock(). Specifically fish
asserts that a lock is locked by asserting that try_lock fails; if it
succeeds fish prints an error and then unlocks the lock (so as not to leave
it locked). This unlock is of course correct, but it confused Coverity Scan.
This commit is contained in:
ridiculousfish
2018-02-08 21:59:52 -08:00
parent 8069939112
commit 3a45cad12e
9 changed files with 47 additions and 23 deletions

View File

@@ -48,7 +48,7 @@ file_access_attempt_t access_file(const wcstring &path, int mode) {
autoload_t::autoload_t(const wcstring &env_var_name_var,
command_removed_function_t cmd_removed_callback)
: lock(), env_var_name(env_var_name_var), command_removed(cmd_removed_callback) {}
: env_var_name(env_var_name_var), command_removed(cmd_removed_callback) {}
void autoload_t::entry_was_evicted(wcstring key, autoload_function_t node) {
// This should only ever happen on the main thread.