Skip to content
Closed
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
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ option(BOOST_COROSIO_BUILD_BENCH "Build boost::corosio benchmarks" ${BOOST_COROS
option(BOOST_COROSIO_BUILD_EXAMPLES "Build boost::corosio examples" ${BOOST_COROSIO_IS_ROOT})
option(BOOST_COROSIO_BUILD_DOCS "Build boost::corosio documentation" OFF)
option(BOOST_COROSIO_MRDOCS_BUILD "Building for MrDocs documentation generation" OFF)
option(BOOST_COROSIO_USE_MODULES "Whether to build boost::corosio using C++20 modules or not" OFF)

# Check if environment variable BOOST_SRC_DIR is set
if (NOT DEFINED BOOST_SRC_DIR AND DEFINED ENV{BOOST_SRC_DIR})
Expand Down Expand Up @@ -185,6 +186,11 @@ add_library(boost_corosio ${BOOST_COROSIO_HEADERS} ${BOOST_COROSIO_SOURCES})
add_library(Boost::corosio ALIAS boost_corosio)
boost_corosio_setup_properties(boost_corosio)

if (BOOST_COROSIO_USE_MODULES)
target_sources(boost_corosio PUBLIC FILE_SET CXX_MODULES BASE_DIRS modules FILES modules/boost_corosio.cppm)
target_compile_definitions(boost_corosio PUBLIC BOOST_COROSIO_USE_MODULES)
endif()

#-------------------------------------------------
#
# WolfSSL
Expand Down
6 changes: 3 additions & 3 deletions example/client/http_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ do_request(
"Host: " + std::string(host) + "\r\n"
"Connection: close\r\n"
"\r\n";
(co_await corosio::write(
stream, capy::const_buffer(request.data(), request.size()))).value();
co_await corosio::write(
stream, capy::const_buffer(request.data(), request.size()));

// Read the entire response
std::string response;
Expand All @@ -59,7 +59,7 @@ run_client(
s.open();

// Connect to the server (throws on error)
(co_await s.connect(corosio::endpoint(addr, port))).value();
co_await s.connect(corosio::endpoint(addr, port));

co_await do_request(s, addr.to_string());
}
Expand Down
5 changes: 5 additions & 0 deletions include/boost/corosio/acceptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#ifndef BOOST_COROSIO_ACCEPTOR_HPP
#define BOOST_COROSIO_ACCEPTOR_HPP

#if !defined(BOOST_COROSIO_SOURCE) && defined(BOOST_COROSIO_USE_MODULES)
import boost.corosio;
#else

#include <boost/corosio/detail/config.hpp>
#include <boost/corosio/detail/except.hpp>
#include <boost/corosio/io_object.hpp>
Expand Down Expand Up @@ -286,3 +290,4 @@ class BOOST_COROSIO_DECL acceptor : public io_object
} // namespace boost

#endif
#endif
5 changes: 5 additions & 0 deletions include/boost/corosio/endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#ifndef BOOST_COROSIO_ENDPOINT_HPP
#define BOOST_COROSIO_ENDPOINT_HPP

#if !defined(BOOST_COROSIO_SOURCE) && defined(BOOST_COROSIO_USE_MODULES)
import boost.corosio;
#else

#include <boost/corosio/detail/config.hpp>
#include <boost/url/ipv4_address.hpp>
#include <boost/url/ipv6_address.hpp>
Expand Down Expand Up @@ -187,3 +191,4 @@ class endpoint
} // namespace boost

#endif
#endif
5 changes: 5 additions & 0 deletions include/boost/corosio/io_buffer_param.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#ifndef BOOST_COROSIO_IO_BUFFER_PARAM_HPP
#define BOOST_COROSIO_IO_BUFFER_PARAM_HPP

#if !defined(BOOST_COROSIO_SOURCE) && defined(BOOST_COROSIO_USE_MODULES)
import boost.corosio;
#else

#include <boost/corosio/detail/config.hpp>
#include <boost/capy/buffers.hpp>

Expand Down Expand Up @@ -383,3 +387,4 @@ class io_buffer_param
} // namespace boost

#endif
#endif
5 changes: 5 additions & 0 deletions include/boost/corosio/io_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#ifndef BOOST_COROSIO_IO_CONTEXT_HPP
#define BOOST_COROSIO_IO_CONTEXT_HPP

#if !defined(BOOST_COROSIO_SOURCE) && defined(BOOST_COROSIO_USE_MODULES)
import boost.corosio;
#else

#include <boost/corosio/detail/config.hpp>
#include <boost/corosio/detail/scheduler.hpp>
#include <boost/corosio/detail/unique_ptr.hpp>
Expand Down Expand Up @@ -433,3 +437,4 @@ get_executor() const noexcept ->
} // namespace boost

#endif
#endif
5 changes: 5 additions & 0 deletions include/boost/corosio/io_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#ifndef BOOST_COROSIO_IO_OBJECT_HPP
#define BOOST_COROSIO_IO_OBJECT_HPP

#if !defined(BOOST_COROSIO_SOURCE) && defined(BOOST_COROSIO_USE_MODULES)
import boost.corosio;
#else

#include <boost/corosio/detail/config.hpp>
#include <boost/capy/ex/execution_context.hpp>

Expand Down Expand Up @@ -70,3 +74,4 @@ class BOOST_COROSIO_DECL io_object
} // namespace boost

#endif
#endif
5 changes: 5 additions & 0 deletions include/boost/corosio/io_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#ifndef BOOST_COROSIO_IO_STREAM_HPP
#define BOOST_COROSIO_IO_STREAM_HPP

#if !defined(BOOST_COROSIO_SOURCE) && defined(BOOST_COROSIO_USE_MODULES)
import boost.corosio;
#else

#include <boost/corosio/detail/config.hpp>
#include <boost/corosio/io_object.hpp>
#include <boost/capy/io_result.hpp>
Expand Down Expand Up @@ -247,3 +251,4 @@ class BOOST_COROSIO_DECL io_stream : public io_object
} // namespace boost

#endif
#endif
5 changes: 5 additions & 0 deletions include/boost/corosio/read.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#ifndef BOOST_COROSIO_READ_HPP
#define BOOST_COROSIO_READ_HPP

#if !defined(BOOST_COROSIO_SOURCE) && defined(BOOST_COROSIO_USE_MODULES)
import boost.corosio;
#else

#include <boost/corosio/detail/config.hpp>
#include <boost/corosio/io_stream.hpp>
#include <boost/capy/io_result.hpp>
Expand Down Expand Up @@ -218,3 +222,4 @@ read(io_stream& ios, std::string& s)
} // namespace boost

#endif
#endif
5 changes: 5 additions & 0 deletions include/boost/corosio/resolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#ifndef BOOST_COROSIO_RESOLVER_HPP
#define BOOST_COROSIO_RESOLVER_HPP

#if !defined(BOOST_COROSIO_SOURCE) && defined(BOOST_COROSIO_USE_MODULES)
import boost.corosio;
#else

#include <boost/corosio/detail/config.hpp>
#include <boost/corosio/detail/except.hpp>
#include <boost/corosio/io_object.hpp>
Expand Down Expand Up @@ -341,3 +345,4 @@ class BOOST_COROSIO_DECL resolver : public io_object
} // namespace boost

#endif
#endif
5 changes: 5 additions & 0 deletions include/boost/corosio/resolver_results.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#ifndef BOOST_COROSIO_RESOLVER_RESULTS_HPP
#define BOOST_COROSIO_RESOLVER_RESULTS_HPP

#if !defined(BOOST_COROSIO_SOURCE) && defined(BOOST_COROSIO_USE_MODULES)
import boost.corosio;
#else

#include <boost/corosio/detail/config.hpp>
#include <boost/corosio/endpoint.hpp>

Expand Down Expand Up @@ -206,3 +210,4 @@ class resolver_results
} // namespace boost

#endif
#endif
5 changes: 5 additions & 0 deletions include/boost/corosio/signal_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#ifndef BOOST_COROSIO_SIGNAL_SET_HPP
#define BOOST_COROSIO_SIGNAL_SET_HPP

#if !defined(BOOST_COROSIO_SOURCE) && defined(BOOST_COROSIO_USE_MODULES)
import boost.corosio;
#else

#include <boost/corosio/detail/config.hpp>
#include <boost/corosio/detail/except.hpp>
#include <boost/corosio/io_object.hpp>
Expand Down Expand Up @@ -355,3 +359,4 @@ class BOOST_COROSIO_DECL signal_set : public io_object
} // namespace boost

#endif
#endif
5 changes: 5 additions & 0 deletions include/boost/corosio/socket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#ifndef BOOST_COROSIO_SOCKET_HPP
#define BOOST_COROSIO_SOCKET_HPP

#if !defined(BOOST_COROSIO_SOURCE) && defined(BOOST_COROSIO_USE_MODULES)
import boost.corosio;
#else

#include <boost/corosio/detail/config.hpp>
#include <boost/corosio/detail/except.hpp>
#include <boost/corosio/io_stream.hpp>
Expand Down Expand Up @@ -335,3 +339,4 @@ class BOOST_COROSIO_DECL socket : public io_stream
} // namespace boost

#endif
#endif
5 changes: 5 additions & 0 deletions include/boost/corosio/tcp_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#ifndef BOOST_COROSIO_TCP_SERVER_HPP
#define BOOST_COROSIO_TCP_SERVER_HPP

#if !defined(BOOST_COROSIO_SOURCE) && defined(BOOST_COROSIO_USE_MODULES)
import boost.corosio;
#else

#include <boost/corosio/detail/config.hpp>
#include <boost/corosio/acceptor.hpp>
#include <boost/corosio/socket.hpp>
Expand Down Expand Up @@ -335,3 +339,4 @@ class BOOST_COROSIO_DECL
} // boost

#endif
#endif
5 changes: 5 additions & 0 deletions include/boost/corosio/timer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#ifndef BOOST_COROSIO_TIMER_HPP
#define BOOST_COROSIO_TIMER_HPP

#if !defined(BOOST_COROSIO_SOURCE) && defined(BOOST_COROSIO_USE_MODULES)
import boost.corosio;
#else

#include <boost/corosio/detail/config.hpp>
#include <boost/corosio/detail/except.hpp>
#include <boost/corosio/io_object.hpp>
Expand Down Expand Up @@ -218,3 +222,4 @@ class BOOST_COROSIO_DECL timer : public io_object
} // namespace boost

#endif
#endif
5 changes: 5 additions & 0 deletions include/boost/corosio/tls/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#ifndef BOOST_COROSIO_TLS_CONTEXT_HPP
#define BOOST_COROSIO_TLS_CONTEXT_HPP

#if !defined(BOOST_COROSIO_SOURCE) && defined(BOOST_COROSIO_USE_MODULES)
import boost.corosio;
#else

#include <boost/corosio/detail/config.hpp>
#include <boost/system/result.hpp>

Expand Down Expand Up @@ -865,3 +869,4 @@ class BOOST_COROSIO_DECL context
} // namespace boost

#endif
#endif
5 changes: 5 additions & 0 deletions include/boost/corosio/tls/openssl_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#ifndef BOOST_COROSIO_TLS_OPENSSL_STREAM_HPP
#define BOOST_COROSIO_TLS_OPENSSL_STREAM_HPP

#if !defined(BOOST_COROSIO_SOURCE) && defined(BOOST_COROSIO_USE_MODULES)
import boost.corosio;
#else

#include <boost/corosio/tls/context.hpp>
#include <boost/corosio/tls/tls_stream.hpp>

Expand Down Expand Up @@ -69,3 +73,4 @@ class BOOST_COROSIO_DECL openssl_stream : public tls_stream
} // namespace boost

#endif
#endif
5 changes: 5 additions & 0 deletions include/boost/corosio/tls/tls_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#ifndef BOOST_COROSIO_TLS_TLS_STREAM_HPP
#define BOOST_COROSIO_TLS_TLS_STREAM_HPP

#if !defined(BOOST_COROSIO_SOURCE) && defined(BOOST_COROSIO_USE_MODULES)
import boost.corosio;
#else

#include <boost/corosio/detail/config.hpp>
#include <boost/capy/io_result.hpp>
#include <boost/corosio/io_stream.hpp>
Expand Down Expand Up @@ -263,3 +267,4 @@ class BOOST_COROSIO_DECL tls_stream : public io_stream
} // namespace boost

#endif
#endif
5 changes: 5 additions & 0 deletions include/boost/corosio/tls/wolfssl_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#ifndef BOOST_COROSIO_TLS_WOLFSSL_STREAM_HPP
#define BOOST_COROSIO_TLS_WOLFSSL_STREAM_HPP

#if !defined(BOOST_COROSIO_SOURCE) && defined(BOOST_COROSIO_USE_MODULES)
import boost.corosio;
#else

#include <boost/corosio/detail/config.hpp>
#include <boost/corosio/tls/context.hpp>
#include <boost/corosio/tls/tls_stream.hpp>
Expand Down Expand Up @@ -71,3 +75,4 @@ class BOOST_COROSIO_DECL
} // namespace boost

#endif
#endif
5 changes: 5 additions & 0 deletions include/boost/corosio/write.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#ifndef BOOST_COROSIO_WRITE_HPP
#define BOOST_COROSIO_WRITE_HPP

#if !defined(BOOST_COROSIO_SOURCE) && defined(BOOST_COROSIO_USE_MODULES)
import boost.corosio;
#else

#include <boost/corosio/detail/config.hpp>
#include <boost/corosio/io_stream.hpp>
#include <boost/capy/io_result.hpp>
Expand Down Expand Up @@ -99,3 +103,4 @@ write(io_stream& ios, ConstBufferSequence const& buffers)
} // namespace boost

#endif
#endif
48 changes: 48 additions & 0 deletions modules/boost_corosio.cppm
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module;

#include <boost/corosio.hpp>

export module boost.corosio;

export namespace boost::corosio {

using corosio::acceptor;
using corosio::endpoint;
using corosio::io_buffer_param;
using corosio::io_context;
using corosio::io_object;
using corosio::io_stream;
using corosio::read;
using corosio::resolve_flags;
using corosio::resolver;
using corosio::resolver_entry;
using corosio::resolver_results;
using corosio::signal_set;
using corosio::socket;
using corosio::tcp_server;
using corosio::timer;
using corosio::write;
using corosio::operator|;
using corosio::operator&;
using corosio::operator&=;
using corosio::operator|=;

// I think this should be in tls
using corosio::tls_stream;
using corosio::openssl_stream;
using corosio::wolfssl_stream;

namespace tls {
using corosio::tls::context;
using corosio::tls::file_format;
using corosio::tls::password_purpose;
using corosio::tls::revocation_policy;
using corosio::tls::role;
using corosio::tls::verify_mode;
using corosio::tls::version;
} // namespace tls


} // namespace boost::corosio


1 change: 1 addition & 0 deletions test/unit/io_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <boost/corosio/io_context.hpp>

#include <boost/capy/concept/executor.hpp>
#include <boost/capy/coro.hpp>

#include <atomic>
#include <chrono>
Expand Down
2 changes: 2 additions & 0 deletions test/unit/resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include <boost/capy/cond.hpp>
#include <boost/capy/ex/run_async.hpp>
#include <boost/capy/task.hpp>
#include <boost/url/ipv4_address.hpp>
#include <boost/url/ipv6_address.hpp>

#include "test_suite.hpp"

Expand Down
Loading