aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/complete.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2016-01-16 16:00:57 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2016-01-16 16:00:57 -0800
commit49d3042bd3e7f4913b91fce9a5c34d41e2648cf7 (patch)
tree157b98278513dcf2d5f0d63bb1aac935a2b47515 /src/complete.cpp
parent701d1411092706a8b636ca9d5c28cbf7e3ab097d (diff)
Simplify locking in complete.cpp
Diffstat (limited to 'src/complete.cpp')
-rw-r--r--src/complete.cpp18
1 files changed, 2 insertions, 16 deletions
diff --git a/src/complete.cpp b/src/complete.cpp
index b8a05e49..e77d1105 100644
--- a/src/complete.cpp
+++ b/src/complete.cpp
@@ -224,23 +224,16 @@ static bool compare_completions_by_order(const completion_entry_t *p1, const com
/** The lock that guards the list of completion entries */
static pthread_mutex_t completion_lock = PTHREAD_MUTEX_INITIALIZER;
-/**
- * The lock that guards the options list of individual completion entries.
- * If both completion_lock and completion_entry_lock are to be taken,
- * completion_lock must be taken first.
- */
-static pthread_mutex_t completion_entry_lock = PTHREAD_MUTEX_INITIALIZER;
-
void completion_entry_t::add_option(const complete_entry_opt_t &opt)
{
- ASSERT_IS_LOCKED(completion_entry_lock);
+ ASSERT_IS_LOCKED(completion_lock);
options.push_front(opt);
}
const option_list_t &completion_entry_t::get_options() const
{
- ASSERT_IS_LOCKED(completion_entry_lock);
+ ASSERT_IS_LOCKED(completion_lock);
return options;
}
@@ -543,9 +536,6 @@ void complete_add(const wchar_t *cmd,
/* Lock the lock that allows us to edit the completion entry list */
scoped_lock lock(completion_lock);
- /* Lock the lock that allows us to edit individual completion entries */
- scoped_lock lock2(completion_entry_lock);
-
completion_entry_t *c;
c = complete_get_exact_entry(cmd, cmd_is_path);
@@ -571,7 +561,6 @@ void complete_add(const wchar_t *cmd,
bool completion_entry_t::remove_option(wchar_t short_opt, const wchar_t *long_opt, int old_mode)
{
ASSERT_IS_LOCKED(completion_lock);
- ASSERT_IS_LOCKED(completion_entry_lock);
if ((short_opt == 0) && (long_opt == 0))
{
this->options.clear();
@@ -626,7 +615,6 @@ void complete_remove(const wchar_t *cmd,
{
CHECK(cmd,);
scoped_lock lock(completion_lock);
- scoped_lock lock2(completion_entry_lock);
completion_entry_t tmp_entry(cmd, cmd_is_path, false);
completion_entry_set_t::iterator iter = completion_set.find(&tmp_entry);
@@ -1160,7 +1148,6 @@ bool completer_t::complete_param(const wcstring &scmd_orig, const wcstring &spop
std::vector<option_list_t> all_options;
{
scoped_lock lock(completion_lock);
- scoped_lock lock2(completion_entry_lock);
for (completion_entry_set_t::const_iterator iter = completion_set.begin(); iter != completion_set.end(); ++iter)
{
const completion_entry_t *i = *iter;
@@ -1877,7 +1864,6 @@ wcstring complete_print()
{
wcstring out;
scoped_lock locker(completion_lock);
- scoped_lock locker2(completion_entry_lock);
// Get a list of all completions in a vector, then sort it by order
std::vector<const completion_entry_t *> all_completions(completion_set.begin(), completion_set.end());