Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions include/beman/net/detail/basic_socket_acceptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#ifndef INCLUDED_BEMAN_NET_DETAIL_BASIC_SOCKET_ACCEPTOR
#define INCLUDED_BEMAN_NET_DETAIL_BASIC_SOCKET_ACCEPTOR

#include "beman/net/detail/socket_base.hpp"
#include <beman/net/detail/io_context.hpp>
#include <beman/net/detail/socket_category.hpp>
#include <system_error>
Expand Down
22 changes: 21 additions & 1 deletion include/beman/net/detail/container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
#ifndef INCLUDED_BEMAN_NET_DETAIL_CONTAINER
#define INCLUDED_BEMAN_NET_DETAIL_CONTAINER

#include <algorithm>
#include <beman/net/detail/netfwd.hpp>
#include <cstddef>
#include <iterator>
#include <optional>
#include <variant>
#include <vector>

Expand All @@ -28,6 +31,10 @@ class beman::net::detail::container {
auto insert(Record r) -> ::beman::net::detail::socket_id;
auto erase(::beman::net::detail::socket_id id) -> void;
auto operator[](::beman::net::detail::socket_id id) -> Record&;
// using iterator = decltype(records)::iterator;
// auto begin() -> iterator;
// auto end() -> iterator;
Comment on lines +34 to +36
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these declarations should either be included and appropriately defined or removed.

auto find(const Record& r) -> ::std::optional<::beman::net::detail::socket_id>;
};

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -55,6 +62,19 @@ inline auto beman::net::detail::container<Record>::operator[](::beman::net::deta
return ::std::get<1>(this->records[::std::size_t(id)]);
}

template <typename Record>
inline auto ::beman::net::detail::container<Record>::find(const Record& r)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This member function can be const.

-> ::std::optional<::beman::net::detail::socket_id> {
auto it = ::std::find_if(records.begin(), records.end(), [&](auto& l) {
return ::std::holds_alternative<Record>(l) && ::std::get<Record>(l) == r;
});

if (it == records.end()) {
return {};
}
return {::beman::net::detail::socket_id(::std::distance(records.begin(), it))};
}

// ----------------------------------------------------------------------------

#endif
#endif
4 changes: 3 additions & 1 deletion include/beman/net/detail/io_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

// ----------------------------------------------------------------------------

#include "beman/net/detail/kqueue_context.hpp"
#include <beman/net/detail/netfwd.hpp>
#include <beman/net/detail/context_base.hpp>
#include <beman/net/detail/io_context_scheduler.hpp>
Expand All @@ -30,7 +31,8 @@ class io_context;
class beman::net::io_context {
private:
::std::unique_ptr<::beman::net::detail::context_base> d_owned{new ::beman::net::detail::poll_context()};
::beman::net::detail::context_base& d_context{*this->d_owned};
// ::std::unique_ptr<::beman::net::detail::context_base> d_owned{new ::beman::net::detail::kqueue_context()};
::beman::net::detail::context_base& d_context{*this->d_owned};

public:
using scheduler_type = ::beman::net::detail::io_context_scheduler;
Expand Down
Loading
Loading