Skip to content

Commit c7e75d4

Browse files
frankistcodebot
authored andcommitted
adt: methods to check the capacity and current size of the byte buffer pool
1 parent f54f607 commit c7e75d4

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

include/srsran/adt/byte_buffer.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ size_t byte_buffer_segment_pool_default_segment_size();
2929
void init_byte_buffer_segment_pool(std::size_t nof_segments,
3030
std::size_t memory_block_size = byte_buffer_segment_pool_default_segment_size());
3131

32+
/// \brief Get total capacity of the byte buffer segment pool in terms of segments.
33+
size_t get_byte_buffer_segment_pool_capacity();
34+
35+
/// \brief Get an estimate of the number of segments of the byte buffer segment pool that are currently available for
36+
/// allocation in the caller thread.
37+
size_t get_byte_buffer_segment_pool_current_size_approx();
38+
3239
/// \brief Non-owning view to a byte sequence.
3340
///
3441
/// The underlying byte sequence is not contiguous in memory. Instead, it is represented as an intrusive linked list of

lib/support/byte_buffer.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ void srsran::init_byte_buffer_segment_pool(std::size_t nof_segments, std::size_t
4141
report_fatal_error_if_not(memory_block_size > 64U, "memory blocks must be larger than the segment control header");
4242
}
4343

44+
size_t srsran::get_byte_buffer_segment_pool_capacity()
45+
{
46+
auto& pool = detail::byte_buffer_segment_pool::get_instance();
47+
return pool.nof_memory_blocks();
48+
}
49+
50+
size_t srsran::get_byte_buffer_segment_pool_current_size_approx()
51+
{
52+
auto& pool = detail::byte_buffer_segment_pool::get_instance();
53+
return pool.get_central_cache_approx_size() + pool.get_local_cache_size();
54+
}
55+
4456
// ------- byte_buffer class -------
4557

4658
void byte_buffer::control_block::destroy_node(node_t* node) const

0 commit comments

Comments
 (0)