Skip to content
Permalink
Browse files

Merge pull request #298 from bareos/dev/franku/master/thread_list_fixup

thread_list: improved list access
  • Loading branch information...
arogge committed Oct 9, 2019
2 parents b298e64 + f90662a commit 681d9b80470bf949149eac8c5a0ad3d6611d87f2
Showing with 7 additions and 5 deletions.
  1. +5 −3 core/src/lib/thread_list.cc
  2. +1 −1 core/src/lib/thread_list.h
  3. +1 −1 core/src/tests/thread_list.cc
@@ -130,8 +130,6 @@ static void WorkerThread(std::unique_ptr<ThreadListItem> item, ThreadList* t)

bool ThreadList::CreateAndAddNewThread(ConfigurationParser* config, void* data)
{
if (!impl_) { return false; }

std::lock_guard<std::mutex> l(impl_->thread_list_mutex_);

if (impl_->thread_list_.size() < impl_->maximum_thread_count_) {
@@ -149,4 +147,8 @@ bool ThreadList::CreateAndAddNewThread(ConfigurationParser* config, void* data)
return false;
}

std::size_t ThreadList::GetSize() const { return impl_->thread_list_.size(); }
std::size_t ThreadList::Size() const
{
std::lock_guard<std::mutex> l(impl_->thread_list_mutex_);
return impl_->thread_list_.size();
}
@@ -41,7 +41,7 @@ class ThreadList {

bool CreateAndAddNewThread(ConfigurationParser* config, void* data);
bool WaitUntilThreadListIsEmpty();
std::size_t GetSize() const;
std::size_t Size() const;

ThreadList(const ThreadList& ohter) = delete;
ThreadList(const ThreadList&& ohter) = delete;
@@ -98,7 +98,7 @@ TEST(thread_list, thread_list_startup_and_shutdown)

t->WaitUntilThreadListIsEmpty();

EXPECT_EQ(t->GetSize(), 0);
EXPECT_EQ(t->Size(), 0);
for (const auto& c : list_of_wait_conditions) {
EXPECT_EQ(c.get()->GetStatus(), WaitCondition::Status::kSuccess);
}

0 comments on commit 681d9b8

Please sign in to comment.
You can’t perform that action at this time.