Skip to content

Commit

Permalink
Better differentiation between anonymous memory and file backed vectors.
Browse files Browse the repository at this point in the history
  • Loading branch information
psiha committed Aug 28, 2024
1 parent 1c1ccf3 commit 36ad9cc
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions include/psi/vm/vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1070,12 +1070,14 @@ class vector
// Extensions
///////////////////////////////////////////////////////////////////////////

auto map_file ( auto const file, flags::named_object_construction_policy const policy ) noexcept { return storage_.map_file ( file, policy ); }
auto map_memory( size_type const size ) noexcept { return storage_.map_memory( size ); }
auto map_file ( auto const file, flags::named_object_construction_policy const policy ) noexcept { BOOST_ASSERT( !has_attached_storage() ); return storage_.map_file ( file, policy ); }
auto map_memory( size_type const size ) noexcept { BOOST_ASSERT( !has_attached_storage() ); return storage_.map_memory( size ); }

void close() noexcept { storage_.close(); }
bool has_attached_storage() const noexcept { return static_cast<bool>( storage_ ); }

bool file_backed() const noexcept { return storage_.file_backed(); }

bool is_open() const noexcept { return static_cast<bool>( storage_ ); }
void close() noexcept { storage_.close(); }

//! <b>Effects</b>: If n is less than or equal to capacity(), this call has no
//! effect. Otherwise, it is a request for allocation of additional memory
Expand Down Expand Up @@ -1103,12 +1105,15 @@ class vector
{
[[ maybe_unused ]] auto const newSpaceBegin{ reinterpret_cast<unsigned char const *>( data() + current_size ) };
[[ maybe_unused ]] auto const newSpaceSize { ( target_size - current_size ) * sizeof( value_type ) };
//std::memset( newSpaceBegin, 0, newSpaceSize );
# if 0
std::memset( newSpaceBegin, 0, newSpaceSize );
# else
BOOST_ASSERT_MSG
(
*std::max_element( newSpaceBegin, newSpaceBegin + newSpaceSize ) == 0,
"Expecting files to be zero-extended"
);
# endif
}
else
{
Expand Down

0 comments on commit 36ad9cc

Please sign in to comment.