Skip to content

Commit

Permalink
remove old aligned_union use
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Oct 6, 2020
1 parent e6b4cfe commit 22e98aa
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 66 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ set(libtorrent_extensions_include_files
set(libtorrent_aux_include_files
alert_manager
aligned_storage
aligned_union
alloca
allocating_handler
array
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,6 @@ HEADERS = \
\
aux_/alert_manager.hpp \
aux_/aligned_storage.hpp \
aux_/aligned_union.hpp \
aux_/alloca.hpp \
aux_/allocating_handler.hpp \
aux_/announce_entry.hpp \
Expand Down
49 changes: 0 additions & 49 deletions include/libtorrent/aux_/aligned_union.hpp

This file was deleted.

1 change: 0 additions & 1 deletion include/libtorrent/aux_/socket_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ see LICENSE file.
#define TORRENT_SOCKET_TYPE

#include "libtorrent/assert.hpp"
#include "libtorrent/aux_/aligned_union.hpp"
#include "libtorrent/aux_/polymorphic_socket.hpp"
#include "libtorrent/aux_/rtc_stream.hpp"
#include "libtorrent/aux_/utp_stream.hpp"
Expand Down
30 changes: 16 additions & 14 deletions src/kademlia/rpc_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ see LICENSE file.

#include <libtorrent/socket_io.hpp> // for print_endpoint
#include <libtorrent/aux_/time.hpp> // for aux::time_now
#include <libtorrent/aux_/aligned_union.hpp>
#include <libtorrent/aux_/ip_helpers.hpp> // for is_v6

#include <type_traits>
Expand Down Expand Up @@ -113,25 +112,28 @@ void observer::set_id(node_id const& id)
if (m_algorithm) m_algorithm->resort_result(this);
}

using observer_storage = aux::aligned_union<1
, find_data_observer
, announce_observer
, put_data_observer
, direct_observer
, get_item_observer
, get_peers_observer
, obfuscated_get_peers_observer
, sample_infohashes_observer
, null_observer
, traversal_observer>::type;
namespace {

std::size_t const observer_storage_size = std::max(
{sizeof(find_data_observer)
, sizeof(announce_observer)
, sizeof(put_data_observer)
, sizeof(direct_observer)
, sizeof(get_item_observer)
, sizeof(get_peers_observer)
, sizeof(obfuscated_get_peers_observer)
, sizeof(sample_infohashes_observer)
, sizeof(null_observer)
, sizeof(traversal_observer)});
}

rpc_manager::rpc_manager(node_id const& our_id
, aux::session_settings const& settings
, routing_table& table
, aux::listen_socket_handle sock
, socket_manager* sock_man
, dht_logger* log)
: m_pool_allocator(sizeof(observer_storage), 10)
: m_pool_allocator(observer_storage_size, 10)
, m_sock(std::move(sock))
, m_sock_man(sock_man)
#ifndef TORRENT_DISABLE_LOGGING
Expand Down Expand Up @@ -177,7 +179,7 @@ void rpc_manager::free_observer(void* ptr)
#if TORRENT_USE_ASSERTS
size_t rpc_manager::allocation_size() const
{
return sizeof(observer_storage);
return observer_storage_size;
}
#endif
#if TORRENT_USE_INVARIANT_CHECKS
Expand Down

0 comments on commit 22e98aa

Please sign in to comment.