Skip to content

Commit

Permalink
adt: methods to check the capacity and current size of the byte buffe…
Browse files Browse the repository at this point in the history
…r pool
  • Loading branch information
frankist authored and codebot committed Jul 30, 2024
1 parent f54f607 commit c7e75d4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/srsran/adt/byte_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ size_t byte_buffer_segment_pool_default_segment_size();
void init_byte_buffer_segment_pool(std::size_t nof_segments,
std::size_t memory_block_size = byte_buffer_segment_pool_default_segment_size());

/// \brief Get total capacity of the byte buffer segment pool in terms of segments.
size_t get_byte_buffer_segment_pool_capacity();

/// \brief Get an estimate of the number of segments of the byte buffer segment pool that are currently available for
/// allocation in the caller thread.
size_t get_byte_buffer_segment_pool_current_size_approx();

/// \brief Non-owning view to a byte sequence.
///
/// The underlying byte sequence is not contiguous in memory. Instead, it is represented as an intrusive linked list of
Expand Down
12 changes: 12 additions & 0 deletions lib/support/byte_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ void srsran::init_byte_buffer_segment_pool(std::size_t nof_segments, std::size_t
report_fatal_error_if_not(memory_block_size > 64U, "memory blocks must be larger than the segment control header");
}

size_t srsran::get_byte_buffer_segment_pool_capacity()
{
auto& pool = detail::byte_buffer_segment_pool::get_instance();
return pool.nof_memory_blocks();
}

size_t srsran::get_byte_buffer_segment_pool_current_size_approx()
{
auto& pool = detail::byte_buffer_segment_pool::get_instance();
return pool.get_central_cache_approx_size() + pool.get_local_cache_size();
}

// ------- byte_buffer class -------

void byte_buffer::control_block::destroy_node(node_t* node) const
Expand Down

0 comments on commit c7e75d4

Please sign in to comment.