Skip to content

Commit

Permalink
thread_list: use unique_ptr for pimpl of class ThreadList
Browse files Browse the repository at this point in the history
  • Loading branch information
franku committed Sep 2, 2019
1 parent 870ed9d commit 16bea07
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions core/src/lib/thread_list.cc
Expand Up @@ -22,11 +22,15 @@
#include "include/bareos.h"
#include "thread_list.h"
#include "include/jcr.h"
#include "include/make_unique.h"
#include "lib/berrno.h"
#include "lib/bsock.h"

#include <algorithm>
#include <condition_variable>
#include <thread>
#include <mutex>
#include <set>

struct ThreadListItem {
std::thread WorkerThread_;
Expand All @@ -53,8 +57,8 @@ struct ThreadListPrivate {
bool WaitForThreadsToShutdown();
};

ThreadList::ThreadList() { impl_ = new ThreadListPrivate; }
ThreadList::~ThreadList() { delete impl_; }
ThreadList::ThreadList() : impl_(std::make_unique<ThreadListPrivate>()) {}
ThreadList::~ThreadList() = default;

void ThreadList::Init(int maximum_thread_count,
std::function<void*(ConfigurationParser* config,
Expand Down
2 changes: 1 addition & 1 deletion core/src/lib/thread_list.h
Expand Up @@ -52,7 +52,7 @@ class ThreadList {
ThreadList& operator=(const ThreadList&& rhs) = delete;

private:
ThreadListPrivate* impl_ = nullptr;
std::unique_ptr<ThreadListPrivate> impl_;
};


Expand Down

0 comments on commit 16bea07

Please sign in to comment.