Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IntrusiveQueue add remove method, iterators, and update test #12246

Merged
merged 3 commits into from
Jun 13, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
List fix remove() and update testing
dagar committed Jun 12, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 79689a06f19783aaee6a0958839c2082dd94d80c
2 changes: 1 addition & 1 deletion src/include/containers/BlockingList.hpp
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ class BlockingList : public List<T>
return List<T>::remove(removeNode);
}

size_t size() const
size_t size()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can make _mutex mutable to leave const.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, you're prompting good const correctness questions.

{
LockGuard lg{_mutex};
return List<T>::size();
8 changes: 7 additions & 1 deletion src/include/containers/List.hpp
Original file line number Diff line number Diff line change
@@ -70,7 +70,13 @@ class List
{
// base case
if (removeNode == _head) {
_head = nullptr;
if (_head->getSibling() != nullptr) {
_head = _head->getSibling();

} else {
_head = nullptr;
}

return true;
}

2 changes: 2 additions & 0 deletions src/systemcmds/tests/test_List.cpp
Original file line number Diff line number Diff line change
@@ -141,6 +141,8 @@ bool ListTest::test_remove()
for (auto t : list1) {
ut_assert_true(t->i != remove_i);
}

ut_assert_true(list1.size() == 100 - remove_i - 1);
}

// list should now be empty