Skip to content

Commit fb73b81

Browse files
vasildryanofsky
authored andcommitted
Change EventLoop::m_task_set to not use boost
EventLoop::m_task_set was unnecessary defined as boost::optional<kj::TaskSet> because it is always initialized. It can, however, possibly be destroyed twice: in the EventLoop::loop() method (conditional) and in the EventLoop destructor when it goes out of scope (unconditional). So, use std::unique_ptr to handle this.
1 parent 138ad67 commit fb73b81

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

include/mp/proxy-io.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <capnp/rpc-twoparty.h>
1616

1717
#include <functional>
18+
#include <memory>
1819
#include <string>
1920

2021
namespace mp {
@@ -199,7 +200,7 @@ class EventLoop
199200
LoggingErrorHandler m_error_handler{*this};
200201

201202
//! Capnp list of pending promises.
202-
boost::optional<kj::TaskSet> m_task_set;
203+
std::unique_ptr<kj::TaskSet> m_task_set;
203204

204205
//! List of connections.
205206
std::list<Connection> m_incoming_connections;

src/mp/proxy.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,16 @@ void Connection::addAsyncCleanup(std::function<void()> fn)
123123
}
124124

125125
EventLoop::EventLoop(const char* exe_name, LogFn log_fn, void* context)
126-
: m_exe_name(exe_name), m_io_context(kj::setupAsyncIo()), m_log_fn(std::move(log_fn)), m_context(context)
126+
: m_exe_name(exe_name),
127+
m_io_context(kj::setupAsyncIo()),
128+
m_log_fn(std::move(log_fn)),
129+
m_context(context),
130+
m_task_set(new kj::TaskSet(m_error_handler))
127131
{
128132
int fds[2];
129133
KJ_SYSCALL(socketpair(AF_UNIX, SOCK_STREAM, 0, fds));
130134
m_wait_fd = fds[0];
131135
m_post_fd = fds[1];
132-
m_task_set.emplace(m_error_handler);
133136
}
134137

135138
EventLoop::~EventLoop()

0 commit comments

Comments
 (0)