Skip to content

Commit

Permalink
Move nullptr initializers to class declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
tszumski committed Nov 27, 2024
1 parent 82bb2cb commit a4cb2a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 3 additions & 3 deletions media-proxy/include/mesh/concurrency.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ class Context {
Context(Context& parent);
Context(Context& parent, std::chrono::milliseconds timeout_ms);

Context *parent;
thread::Channel<bool> *ch;
Context *parent = nullptr;
thread::Channel<bool> *ch = nullptr;
std::future<void> async_cb;
std::chrono::milliseconds timeout_ms;
std::unique_ptr<std::stop_callback<std::function<void()>>> cb;
std::unique_ptr<std::stop_callback<std::function<void()>>> cb = nullptr;

friend Context& Background();
friend class WithCancel;
Expand Down
5 changes: 1 addition & 4 deletions media-proxy/src/mesh/concurrency.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ namespace mesh {
namespace context {

Context::Context() : ss(std::stop_source()),
parent(nullptr),
cb(nullptr),
ch(nullptr),
timeout_ms(std::chrono::milliseconds(0))
{
}
Expand Down Expand Up @@ -55,7 +52,7 @@ Context& Context::operator=(Context&& other) noexcept {
ss = std::stop_source();
parent = other.parent;

if(parent){
if (parent) {
cb = std::make_unique<std::stop_callback<std::function<void()>>>(
parent->ss.get_token(), [this] { cancel(); }
);
Expand Down

0 comments on commit a4cb2a9

Please sign in to comment.