include/boost/corosio/native/detail/kqueue/kqueue_tcp_acceptor.hpp

-% Lines (0/0) -% List of functions (0/0) -% Branches (0/0)
Line TLA Hits Source Code
1 //
2 // Copyright (c) 2026 Michael Vandeberg
3 // Copyright (c) 2026 Steve Gerbino
4 //
5 // Distributed under the Boost Software License, Version 1.0. (See accompanying
6 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 //
8 // Official repository: https://github.com/cppalliance/corosio
9 //
10
11 #ifndef BOOST_COROSIO_NATIVE_DETAIL_KQUEUE_KQUEUE_TCP_ACCEPTOR_HPP
12 #define BOOST_COROSIO_NATIVE_DETAIL_KQUEUE_KQUEUE_TCP_ACCEPTOR_HPP
13
14 #include <boost/corosio/detail/platform.hpp>
15
16 #if BOOST_COROSIO_HAS_KQUEUE
17
18 #include <boost/corosio/native/detail/reactor/reactor_acceptor.hpp>
19 #include <boost/corosio/native/detail/kqueue/kqueue_op.hpp>
20 #include <boost/capy/ex/executor_ref.hpp>
21
22 namespace boost::corosio::detail {
23
24 class kqueue_tcp_acceptor_service;
25
26 /// Acceptor implementation for kqueue backend.
27 class kqueue_tcp_acceptor final
28 : public reactor_acceptor<
29 kqueue_tcp_acceptor,
30 kqueue_tcp_acceptor_service,
31 kqueue_op,
32 kqueue_accept_op,
33 descriptor_state>
34 {
35 friend class kqueue_tcp_acceptor_service;
36
37 public:
38 explicit kqueue_tcp_acceptor(kqueue_tcp_acceptor_service& svc) noexcept;
39
40 /** Initiate an asynchronous accept on the listening socket.
41
42 Attempts a synchronous accept first. If the socket would block
43 (EAGAIN), the operation is parked in desc_state_ until the
44 reactor delivers a read-readiness event, at which point the
45 accept is retried. On completion (success, error, or
46 cancellation) the operation is posted to the scheduler and
47 @a caller is resumed via @a ex.
48
49 Only one accept may be outstanding at a time; overlapping
50 calls produce undefined behavior.
51
52 @param caller Coroutine handle resumed on completion.
53 @param ex Executor through which @a caller is resumed.
54 @param token Stop token for cancellation.
55 @param ec Points to storage for the result error code.
56 @param out_impl Points to storage for the accepted socket impl.
57
58 @return std::noop_coroutine() unconditionally.
59 */
60 std::coroutine_handle<> accept(
61 std::coroutine_handle<> caller,
62 capy::executor_ref ex,
63 std::stop_token token,
64 std::error_code* ec,
65 io_object::implementation** out_impl) override;
66
67 void cancel() noexcept override;
68 void close_socket() noexcept;
69 };
70
71 } // namespace boost::corosio::detail
72
73 #endif // BOOST_COROSIO_HAS_KQUEUE
74
75 #endif // BOOST_COROSIO_NATIVE_DETAIL_KQUEUE_KQUEUE_TCP_ACCEPTOR_HPP
76