Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions test/doc/reference/io_context__service.record.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// Copyright (c) 2026 Steve Gerbino
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/cppalliance/corosio
//

// Reference example injected into the documentation for
// io_context::service by doc/addons/extensions/reference-snippets.lua.
// The symbol is inherited from capy::execution_context (declared in
// boost/capy/ex/execution_context.hpp); MrDocs lists it under io_context,
// so the inherited docstring's example marker resolves against this file.
// The tagged region is what the reference renders; scaffolding stays
// outside the tags.

#include "../doc_warnings.hpp"

#include <boost/corosio/io_context.hpp>

#include <tuple>

namespace corosio = boost::corosio;
namespace capy = boost::capy;

namespace {

namespace ex_1 {
// tag::example[]
struct my_service : capy::execution_context::service
{
explicit my_service(capy::execution_context&) {}

protected:
void shutdown() override
{
// Cancel pending operations, release resources
}
};

void register_service()
{
corosio::io_context ioc;

// Created on first use, owned by the context for its lifetime
auto& svc = ioc.use_service<my_service>();
std::ignore = svc;
}
// end::example[]
} // namespace ex_1

} // namespace
Loading