Skip to content
Merged
Show file tree
Hide file tree
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
688 changes: 617 additions & 71 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ file(GLOB_RECURSE BOOST_COROSIO_HEADERS CONFIGURE_DEPENDS
file(GLOB_RECURSE BOOST_COROSIO_SOURCES CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
# Exclude wolfssl files from main library (they are added separately when WolfSSL is found)
list(FILTER BOOST_COROSIO_HEADERS EXCLUDE REGEX ".*/wolfssl/.*")
list(FILTER BOOST_COROSIO_SOURCES EXCLUDE REGEX ".*/wolfssl/.*")

source_group("" FILES "include/boost/corosio.hpp")
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/include/boost/corosio" PREFIX "include" FILES ${BOOST_COROSIO_HEADERS})
Expand All @@ -147,6 +150,7 @@ function(boost_corosio_setup_properties target)
$<$<PLATFORM_ID:Windows>:ws2_32>)
target_compile_definitions(${target} PUBLIC BOOST_COROSIO_NO_LIB)
target_compile_definitions(${target} PRIVATE BOOST_COROSIO_SOURCE)
target_compile_definitions(${target} PRIVATE $<$<PLATFORM_ID:Windows>:_WIN32_WINNT=0x0602>)
if (BUILD_SHARED_LIBS)
target_compile_definitions(${target} PUBLIC BOOST_COROSIO_DYN_LINK)
else ()
Expand All @@ -157,6 +161,21 @@ function(boost_corosio_setup_properties target)
$<$<CXX_COMPILER_ID:GNU>:-fcoroutines>)
endfunction()

#-------------------------------------------------
#
# MrDocs Build (minimal for documentation)
#
#-------------------------------------------------
if (BOOST_COROSIO_MRDOCS_BUILD)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/mrdocs.cpp"
"#include <boost/corosio.hpp>\n")
add_library(boost_corosio_mrdocs "${CMAKE_CURRENT_BINARY_DIR}/mrdocs.cpp")
boost_corosio_setup_properties(boost_corosio_mrdocs)
target_compile_definitions(boost_corosio_mrdocs PUBLIC BOOST_COROSIO_MRDOCS)
set_target_properties(boost_corosio_mrdocs PROPERTIES EXPORT_COMPILE_COMMANDS ON)
return()
endif()

add_library(boost_corosio ${BOOST_COROSIO_HEADERS} ${BOOST_COROSIO_SOURCES})
add_library(Boost::corosio ALIAS boost_corosio)
boost_corosio_setup_properties(boost_corosio)
Expand Down
13 changes: 11 additions & 2 deletions build/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import config : requires ;

constant c20-requires :
[ requires
cxx20_constexpr
cxx20_hdr_concepts
]
;

Expand All @@ -31,7 +31,15 @@ project boost/corosio
: source-location $(COROSIO_ROOT)
;

alias corosio_sources : [ glob-tree-ex $(COROSIO_ROOT)/src/src : *.cpp ] ;
local COROSIO_SRC =
[ glob $(COROSIO_ROOT)/src/*.cpp ]
[ glob $(COROSIO_ROOT)/src/detail/*.cpp ]
;

alias corosio_sources : $(COROSIO_SRC) ;

# System libraries
lib ws2_32 ;

lib boost_corosio
: corosio_sources
Expand All @@ -40,6 +48,7 @@ lib boost_corosio
<library>/boost/url//boost_url
<library>/boost/system//boost_system
<target-os>windows:<library>ws2_32
<target-os>windows:<define>_WIN32_WINNT=0x0602
<include>$(COROSIO_ROOT)/include
<include>$(COROSIO_ROOT)/src
: usage-requirements
Expand Down
7 changes: 1 addition & 6 deletions include/boost/corosio/acceptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace corosio {
}
@endcode
*/
class acceptor : public io_object
class BOOST_COROSIO_DECL acceptor : public io_object
{
struct accept_awaitable
{
Expand Down Expand Up @@ -123,14 +123,12 @@ class acceptor : public io_object

Closes the acceptor if open, cancelling any pending operations.
*/
BOOST_COROSIO_DECL
~acceptor();

/** Construct an acceptor from an execution context.

@param ctx The execution context that will own this acceptor.
*/
BOOST_COROSIO_DECL
explicit acceptor(capy::execution_context& ctx);

/** Construct an acceptor from an executor.
Expand Down Expand Up @@ -202,15 +200,13 @@ class acceptor : public io_object

@throws std::system_error on failure.
*/
BOOST_COROSIO_DECL
void listen(endpoint ep, int backlog = 128);

/** Close the acceptor.

Releases acceptor resources. Any pending operations complete
with `errc::operation_canceled`.
*/
BOOST_COROSIO_DECL
void close();

/** Check if the acceptor is listening.
Expand Down Expand Up @@ -264,7 +260,6 @@ class acceptor : public io_object

All outstanding operations complete with `errc::operation_canceled`.
*/
BOOST_COROSIO_DECL
void cancel();

struct acceptor_impl : io_object_impl
Expand Down
4 changes: 1 addition & 3 deletions include/boost/corosio/io_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace corosio {
ioc.run(); // Process all queued work
@endcode
*/
class io_context : public capy::execution_context
class BOOST_COROSIO_DECL io_context : public capy::execution_context
{
public:
class executor_type;
Expand All @@ -59,7 +59,6 @@ class io_context : public capy::execution_context
available on the system. If more than one thread is available,
thread-safe synchronization is used.
*/
BOOST_COROSIO_DECL
io_context();

/** Construct an io_context with a concurrency hint.
Expand All @@ -68,7 +67,6 @@ class io_context : public capy::execution_context
will call `run()`. If greater than 1, thread-safe
synchronization is used internally.
*/
BOOST_COROSIO_DECL
explicit
io_context(unsigned concurrency_hint);

Expand Down
2 changes: 1 addition & 1 deletion include/boost/corosio/io_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace corosio {
The implementation pointer is accessible to derived classes
through the protected member `impl_`.
*/
class io_object
class BOOST_COROSIO_DECL io_object
{
public:
struct io_object_impl
Expand Down
2 changes: 1 addition & 1 deletion include/boost/corosio/io_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace boost {
namespace corosio {

class io_stream : public io_object
class BOOST_COROSIO_DECL io_stream : public io_object
{
public:
/** Initiate an asynchronous read operation.
Expand Down
5 changes: 1 addition & 4 deletions include/boost/corosio/resolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ operator&=(resolve_flags& a, resolve_flags b) noexcept
auto results = (co_await r.resolve("www.example.com", "https")).value();
@endcode
*/
class resolver : public io_object
class BOOST_COROSIO_DECL resolver : public io_object
{
struct resolve_awaitable
{
Expand Down Expand Up @@ -198,14 +198,12 @@ class resolver : public io_object

Cancels any pending operations.
*/
BOOST_COROSIO_DECL
~resolver();

/** Construct a resolver from an execution context.

@param ctx The execution context that will own this resolver.
*/
BOOST_COROSIO_DECL
explicit resolver(capy::execution_context& ctx);

/** Construct a resolver from an executor.
Expand Down Expand Up @@ -313,7 +311,6 @@ class resolver : public io_object

All outstanding operations complete with `errc::operation_canceled`.
*/
BOOST_COROSIO_DECL
void cancel();

public:
Expand Down
7 changes: 1 addition & 6 deletions include/boost/corosio/socket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace corosio {
auto bytes = (co_await s.read_some(buf)).value();
@endcode
*/
class socket : public io_stream
class BOOST_COROSIO_DECL socket : public io_stream
{
public:
struct socket_impl : io_stream_impl
Expand Down Expand Up @@ -134,14 +134,12 @@ class socket : public io_stream

Closes the socket if open, cancelling any pending operations.
*/
BOOST_COROSIO_DECL
~socket();

/** Construct a socket from an execution context.

@param ctx The execution context that will own this socket.
*/
BOOST_COROSIO_DECL
explicit socket(capy::execution_context& ctx);

/** Construct a socket from an executor.
Expand Down Expand Up @@ -207,15 +205,13 @@ class socket : public io_stream

@throws std::system_error on failure.
*/
BOOST_COROSIO_DECL
void open();

/** Close the socket.

Releases socket resources. Any pending operations complete
with `errc::operation_canceled`.
*/
BOOST_COROSIO_DECL
void close();

/** Check if the socket is open.
Expand Down Expand Up @@ -270,7 +266,6 @@ class socket : public io_stream

All outstanding operations complete with `errc::operation_canceled`.
*/
BOOST_COROSIO_DECL
void cancel();

private:
Expand Down
5 changes: 2 additions & 3 deletions include/boost/corosio/wolfssl_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace corosio {
// Use secure stream for TLS communication
@endcode
*/
class wolfssl_stream : public io_stream
class BOOST_COROSIO_DECL wolfssl_stream : public io_stream
{
struct handshake_awaitable
{
Expand Down Expand Up @@ -109,7 +109,6 @@ class wolfssl_stream : public io_stream

@param stream Reference to the underlying stream to wrap.
*/
BOOST_COROSIO_DECL
explicit
wolfssl_stream(io_stream& stream);

Expand Down Expand Up @@ -161,7 +160,7 @@ class wolfssl_stream : public io_stream
};

private:
BOOST_COROSIO_DECL void construct();
void construct();

wolfssl_stream_impl& get() const noexcept
{
Expand Down
11 changes: 8 additions & 3 deletions src/detail/posix_scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void
posix_scheduler::
post(capy::any_coro h) const
{
struct post_handler
struct post_handler final
: capy::execution_context::handler
{
capy::any_coro h_;
Expand All @@ -145,6 +145,8 @@ post(capy::any_coro h) const
{
}

~post_handler() = default;

void operator()() override
{
auto h = h_;
Expand Down Expand Up @@ -387,8 +389,10 @@ posix_scheduler::
wakeup() const
{
// Write to eventfd to wake up epoll_wait
// Return value intentionally ignored - eventfd write cannot fail
// when buffer has space (counter won't overflow with uint64_t max)
std::uint64_t val = 1;
::write(event_fd_, &val, sizeof(val));
[[maybe_unused]] auto r = ::write(event_fd_, &val, sizeof(val));
}

// RAII guard - work_finished called even if handler throws
Expand Down Expand Up @@ -453,8 +457,9 @@ do_one(long timeout_us)
if (events[i].data.ptr == nullptr)
{
// eventfd wakeup - drain it
// Return value intentionally ignored - we just need to consume the event
std::uint64_t val;
::read(event_fd_, &val, sizeof(val));
[[maybe_unused]] auto r = ::read(event_fd_, &val, sizeof(val));
continue;
}

Expand Down
7 changes: 7 additions & 0 deletions src/detail/win_iocp_resolver_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
#include <boost/url/ipv4_address.hpp>
#include <boost/url/ipv6_address.hpp>

// MinGW may not have GetAddrInfoExCancel declared
#if defined(__MINGW32__) || defined(__MINGW64__)
extern "C" {
INT WSAAPI GetAddrInfoExCancel(LPHANDLE lpHandle);
}
#endif

namespace boost {
namespace corosio {
namespace detail {
Expand Down
4 changes: 3 additions & 1 deletion src/detail/win_iocp_scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ void
win_iocp_scheduler::
post(capy::any_coro h) const
{
struct post_handler
struct post_handler final
: capy::execution_context::handler
{
capy::any_coro h_;
Expand All @@ -180,6 +180,8 @@ post(capy::any_coro h) const
{
}

~post_handler() = default;

void operator()() override
{
auto h = h_;
Expand Down
10 changes: 10 additions & 0 deletions test/Jamfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# 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
#

build-project unit ;
Loading
Loading