Skip to content

Commit

Permalink
make controller_run_result become movable.
Browse files Browse the repository at this point in the history
Fixes #106

This allows a consuming application to store this for later processing (i.e. for shutting down the server without terminating the application itself).
Also ensure that `controller_run_result` is not copyable.
  • Loading branch information
Joel Bodenmann committed Jan 16, 2022
1 parent a093181 commit 5874a5a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/malloy/core/detail/controller_run_result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace malloy::detail
};

template<typename T>
requires std::movable<T>
class controller_run_result
{
public:
Expand Down Expand Up @@ -65,6 +66,19 @@ namespace malloy::detail
cfg.logger->debug("starting i/o context.");
}

/**
* Move constructor.
*/
controller_run_result(controller_run_result&&) noexcept = default;

/**
* Move-assignment operator.
*/
controller_run_result& operator=(controller_run_result&&) noexcept = default;

controller_run_result(const controller_run_result&) = delete;
controller_run_result& operator=(const controller_run_result&) = delete;

/**
* Destructor.
*/
Expand All @@ -73,11 +87,13 @@ namespace malloy::detail
// Stop the `io_context`. This will cause `run()`
// to return immediately, eventually destroying the
// `io_context` and all of the sockets in it.
m_io_ctx->stop();
if (m_io_ctx)
m_io_ctx->stop();

// Tell the workguard that we no longer need it's service
m_workguard.reset();

// Join threads
for (auto& thread : m_io_threads)
thread.join();
}
Expand Down

0 comments on commit 5874a5a

Please sign in to comment.