Tectu / malloy

A cross-platform C++20 library providing embeddable server & client components for HTTP and WebSocket.
BSD 3-Clause "New" or "Revised" License
68 stars 8 forks source link

controller i/o threads reservation #120

Closed Tectu closed 2 years ago

Tectu commented 2 years ago

In controller_run_result's constructor we have this piece of code:

// Create the I/O context threads
m_io_threads.reserve(cfg.num_threads - 1);
for (std::size_t i = 0; i < cfg.num_threads; i++) {
    m_io_threads.emplace_back(
        [m_io_ctx = m_io_ctx.get()] { // We cannot capture `this` as we may be moved from before this executes
            assert(m_io_ctx);
            m_io_ctx->run();
        });
}

It would seem that the call to std::vector::reserve() incorrectly does -1. On first glance, this seems like a simple mistake. Investigate and fix this (if necessary).