A linkable portion of IOBufferData. More...
#include <I_IOBuffer.h>
Inherits RefCountObj.
Public Member Functions | |
char * | buf () |
Access the actual data. | |
char * | start () |
Beginning of the inuse section. | |
char * | end () |
End of the used space. | |
char * | buf_end () |
End of the data buffer. | |
int64_t | size () |
Size of the inuse area. | |
int64_t | read_avail () |
Size of the data available for reading. | |
int64_t | write_avail () |
Space available in the buffer. | |
int64_t | block_size () |
Size of the memory allocated by the underlying IOBufferData. | |
void | consume (int64_t len) |
Decrease the size of the inuse area. | |
void | fill (int64_t len) |
Increase the inuse area of the block. | |
void | reset () |
Reset the inuse area. | |
IOBufferBlock * | clone () |
Create a copy of the IOBufferBlock. | |
void | clear () |
Clear the IOBufferData this IOBufferBlock handles. | |
void | alloc (int64_t i=default_large_iobuffer_size) |
Allocate a data buffer. | |
void | dealloc () |
Clear the IOBufferData this IOBufferBlock handles. | |
void | set (IOBufferData *d, int64_t len=0, int64_t offset=0) |
Set or replace this IOBufferBlock's IOBufferData member. | |
void | set_internal (void *b, int64_t len, int64_t asize_index) |
void | realloc_set_internal (void *b, int64_t buf_size, int64_t asize_index) |
void | realloc (void *b, int64_t buf_size) |
void | realloc (int64_t i) |
void | realloc_xmalloc (void *b, int64_t buf_size) |
void | realloc_xmalloc (int64_t buf_size) |
virtual void | free () |
Frees the IOBufferBlock object and its underlying memory. | |
IOBufferBlock () | |
Constructor of a IOBufferBlock. | |
Data Fields | |
char * | _start |
char * | _end |
char * | _buf_end |
const char * | _location |
Ptr< IOBufferData > | data |
The underlying reference to the allocated memory. | |
Ptr< IOBufferBlock > | next |
Reference to another IOBufferBlock. |
A linkable portion of IOBufferData.
IOBufferBlock is a chainable buffer block descriptor. The IOBufferBlock represents both the used and available space in the underlying block. The IOBufferBlock is not sharable between buffers but rather represents what part of the data block is both in use and usable by the MIOBuffer it is attached to.
Definition at line 295 of file I_IOBuffer.h.
TS_INLINE IOBufferBlock::IOBufferBlock | ( | ) |
Constructor of a IOBufferBlock.
Do not use it to create a new object, instead call new_IOBufferBlock
Definition at line 380 of file P_IOBuffer.h.
TS_INLINE void IOBufferBlock::alloc | ( | int64_t | i = default_large_iobuffer_size |
) |
Allocate a data buffer.
Allocates a data buffer for this IOBufferBlock based on index 'i'. Index values are described in the remarks section in MIOBuffer.
Definition at line 414 of file P_IOBuffer.h.
References _location, BUFFER_SIZE_ALLOCATED, data, ink_assert, new_IOBufferData_internal(), and reset().
Referenced by MIOBuffer::append_block(), INKUDPSendTo(), new_incoming_UDPPacket(), new_UDPPacket(), and test_main().
int64_t IOBufferBlock::block_size | ( | ) | [inline] |
Size of the memory allocated by the underlying IOBufferData.
Computes the size of the entire block, which includes the used and available areas. It is the memory allocated by the IOBufferData referenced by this IOBufferBlock.
Definition at line 388 of file I_IOBuffer.h.
References data.
Referenced by test_main().
char* IOBufferBlock::buf | ( | ) | [inline] |
Access the actual data.
Provides access to rhe underlying data managed by the IOBufferData.
Definition at line 305 of file I_IOBuffer.h.
References data.
Referenced by HdrHeap::attach_block(), MIOBuffer::buf(), reset(), and set().
char* IOBufferBlock::buf_end | ( | ) | [inline] |
End of the data buffer.
Returns a pointer to end of the data buffer represented by this block.
Definition at line 339 of file I_IOBuffer.h.
References _buf_end.
Referenced by MIOBuffer::buf_end().
TS_INLINE void IOBufferBlock::clear | ( | ) |
Clear the IOBufferData this IOBufferBlock handles.
Clears this IOBufferBlock's reference to the data buffer (IOBufferData). You can use alloc after this call to allocate an IOBufferData associated to this IOBufferBlock.
Definition at line 426 of file P_IOBuffer.h.
References _buf_end, _end, _start, data, free(), Ptr< T >::m_ptr, next, and RefCountObj::refcount_dec().
Referenced by dealloc().
TS_INLINE IOBufferBlock * IOBufferBlock::clone | ( | ) |
Create a copy of the IOBufferBlock.
Creates and returns a copy of this IOBufferBlock that references the same data that this IOBufferBlock (it does not allocate an another buffer). The cloned block will not have a writable space since the original IOBufferBlock mantains the ownership for writing data to the block.
Definition at line 446 of file P_IOBuffer.h.
References _buf_end, _end, _location, _start, data, and new_IOBufferBlock_internal().
Referenced by clone_IOBufferBlockList(), consume_IOBufferBlockList(), iobufferblock_clone(), NetTesterSM::NetTesterSM(), new_UDPPacket(), and MIOBuffer::write().
TS_INLINE void IOBufferBlock::consume | ( | int64_t | len | ) |
Decrease the size of the inuse area.
Moves forward the start of the inuse area. This also decreases the number of available bytes for reading.
len | bytes to consume or positions to skip for the start of the inuse area. |
Definition at line 393 of file P_IOBuffer.h.
References _end, _start, and ink_assert.
Referenced by clone_IOBufferBlockList(), and consume_IOBufferBlockList().
TS_INLINE void IOBufferBlock::dealloc | ( | ) |
Clear the IOBufferData this IOBufferBlock handles.
Clears this IOBufferBlock's reference to the data buffer (IOBufferData).
Definition at line 464 of file P_IOBuffer.h.
References clear().
Referenced by free(), and realloc_set_internal().
char* IOBufferBlock::end | ( | ) | [inline] |
End of the used space.
Returns a pointer to end of the used space in the data buffer represented by this block.
Definition at line 329 of file I_IOBuffer.h.
References _end.
Referenced by HdrHeap::attach_block(), PrefetchBlaster::blastObject(), MIOBuffer::end(), new_incoming_UDPPacket(), new_UDPPacket(), UDPNetProcessor::recvfrom_re(), ssl_read_from_net(), TSHttpHdrPrint(), TSIOBufferBlockWriteStart(), TSMimeHdrPrint(), and TSUrlPrint().
TS_INLINE void IOBufferBlock::fill | ( | int64_t | len | ) |
Increase the inuse area of the block.
Adds 'len' bytes to the inuse area of the block. Data should be copied into the data buffer by using end() to find the start of the free space in the data buffer before calling fill()
len | bytes to increase the inuse area. It must be less than or equal to the value of write_avail(). |
Definition at line 400 of file P_IOBuffer.h.
References _buf_end, _end, and ink_assert.
Referenced by PrefetchBlaster::blastObject(), clone_IOBufferBlockList(), consume_IOBufferBlockList(), INKUDPSendTo(), new_incoming_UDPPacket(), new_UDPPacket(), UDPNetProcessor::recvfrom_re(), and test_main().
TS_INLINE void IOBufferBlock::free | ( | ) | [virtual] |
Frees the IOBufferBlock object and its underlying memory.
Removes the reference to the IOBufferData object and then frees itself. You should not use this object or reference after this call.
Reimplemented from RefCountObj.
Definition at line 470 of file P_IOBuffer.h.
References dealloc(), ioBlockAllocator, this_thread(), and THREAD_FREE.
Referenced by agg_copy(), clear(), PrefetchBlaster::free(), and TSIOBufferBlockDestroy().
int64_t IOBufferBlock::read_avail | ( | ) | [inline] |
Size of the data available for reading.
Returns the size of the data available for reading in the inuse area.
Definition at line 362 of file I_IOBuffer.h.
Referenced by MIOBuffer::append_block(), MIOBuffer::append_block_internal(), PrefetchBlaster::blastObject(), bytes_IOBufferBlockList(), clone_IOBufferBlockList(), consume_IOBufferBlockList(), ClusterHandler::finish_delayed_reads(), FetchSM::get_info_from_buffer(), UDPPacket::getPktLength(), iobufferblock_skip(), IOBufferReader::is_read_avail_more_than(), UnixNetVConnection::load_buffer_and_write(), SSLNetVConnection::load_buffer_and_write(), IOBufferReader::memchr(), IOBufferReader::memcpy(), IOBufferReader::operator[](), IOBufferReader::read_avail(), TSIOBufferBlockDataSizeGet(), TSIOBufferBlockReadAvail(), TSIOBufferBlockReadStart(), PrefetchUrlBlaster::udpUrlBlaster(), and MIOBuffer::write().
TS_INLINE void IOBufferBlock::realloc | ( | void * | b, | |
int64_t | buf_size | |||
) |
Definition at line 513 of file P_IOBuffer.h.
References BUFFER_SIZE_NOT_ALLOCATED, and realloc_set_internal().
TS_INLINE void IOBufferBlock::realloc | ( | int64_t | i | ) |
Definition at line 531 of file P_IOBuffer.h.
References Allocator::alloc_void(), BUFFER_SIZE_FOR_INDEX, BUFFER_SIZE_NOT_ALLOCATED, countof, data, ink_release_assert, ioBufAllocator, and realloc_set_internal().
TS_INLINE void IOBufferBlock::realloc_set_internal | ( | void * | b, | |
int64_t | buf_size, | |||
int64_t | asize_index | |||
) |
Definition at line 503 of file P_IOBuffer.h.
References _end, _start, dealloc(), memcpy, set_internal(), and size().
Referenced by realloc(), and realloc_xmalloc().
TS_INLINE void IOBufferBlock::realloc_xmalloc | ( | void * | b, | |
int64_t | buf_size | |||
) |
Definition at line 519 of file P_IOBuffer.h.
References realloc_set_internal().
TS_INLINE void IOBufferBlock::realloc_xmalloc | ( | int64_t | buf_size | ) |
Definition at line 525 of file P_IOBuffer.h.
References ats_malloc(), and realloc_set_internal().
TS_INLINE void IOBufferBlock::reset | ( | ) |
Reset the inuse area.
The start and end of the inuse area are reset but the actual IOBufferData referenced by this IOBufferBlock is not modified. This effectively reduces the number of bytes available for reading to zero, and the number of bytes available for writing to the size of the entire buffer.
Definition at line 407 of file P_IOBuffer.h.
References _buf_end, _end, _start, buf(), and data.
Referenced by alloc(), PrefetchBlaster::blastObject(), and set_internal().
TS_INLINE void IOBufferBlock::set | ( | IOBufferData * | d, | |
int64_t | len = 0 , |
|||
int64_t | offset = 0 | |||
) |
Set or replace this IOBufferBlock's IOBufferData member.
Sets this IOBufferBlock's IOBufferData member to point to the IOBufferData passed in. You can optionally specify the inuse area with the 'len' argument and an offset for the start.
d | new IOBufferData this IOBufferBlock references. | |
len | in use area to set. It must be less than or equal to the length of the block size *IOBufferData). | |
offset | bytes to skip from the beginning of the IOBufferData and to mark its start. |
Definition at line 494 of file P_IOBuffer.h.
References _buf_end, _end, _start, IOBufferData::block_size(), buf(), and data.
Referenced by new_IOBufferBlock_internal().
TS_INLINE void IOBufferBlock::set_internal | ( | void * | b, | |
int64_t | len, | |||
int64_t | asize_index | |||
) |
Definition at line 477 of file P_IOBuffer.h.
References _end, _location, _start, BUFFER_SIZE_NOT_ALLOCATED, data, new_IOBufferData_internal(), and reset().
Referenced by MIOBuffer::append_fast_allocated(), MIOBuffer::append_xmalloced(), and realloc_set_internal().
int64_t IOBufferBlock::size | ( | ) | [inline] |
Size of the inuse area.
Returns the size of the current inuse area.
Definition at line 350 of file I_IOBuffer.h.
Referenced by realloc_set_internal(), and UDPQueue::SendUDPPacket().
char* IOBufferBlock::start | ( | ) | [inline] |
Beginning of the inuse section.
Returns the position in the buffer where the inuse area begins.
Definition at line 317 of file I_IOBuffer.h.
References _start.
Referenced by HdrHeap::attach_block(), PrefetchBlaster::blastObject(), FetchSM::get_info_from_buffer(), INKUDPSendTo(), UnixNetVConnection::load_buffer_and_write(), SSLNetVConnection::load_buffer_and_write(), IOBufferReader::memchr(), IOBufferReader::memcpy(), IOBufferReader::operator[](), UDPQueue::SendUDPPacket(), MIOBuffer::start(), test_main(), TSIOBufferBlockReadStart(), PrefetchUrlBlaster::udpUrlBlaster(), and HttpSM::write_header_into_buffer().
int64_t IOBufferBlock::write_avail | ( | ) | [inline] |
Space available in the buffer.
Returns the number of bytes that can be written to the data buffer.
Definition at line 373 of file I_IOBuffer.h.
References _buf_end, and _end.
Referenced by PrefetchBlaster::blastObject(), MIOBuffer::block_write_avail(), bytes_IOBufferBlockList(), MIOBuffer::current_write_avail(), read_from_net(), UDPNetProcessor::recvfrom_re(), ssl_read_from_net(), HttpSM::state_read_client_request_header(), TSHttpHdrPrint(), TSIOBufferBlockWriteAvail(), TSIOBufferBlockWriteStart(), TSIOBufferStart(), TSMimeHdrPrint(), TSUrlPrint(), and HttpSM::write_header_into_buffer().
char* IOBufferBlock::_buf_end |
Definition at line 494 of file I_IOBuffer.h.
Referenced by buf_end(), clear(), clone(), fill(), iobufferblock_clone(), CacheVC::openReadMain(), reset(), set(), MIOBuffer::write(), and write_avail().
char* IOBufferBlock::_end |
Definition at line 493 of file I_IOBuffer.h.
Referenced by clear(), clone(), consume(), end(), fill(), iobufferblock_clone(), iobufferblock_memcpy(), CacheVC::openReadMain(), read_avail(), read_from_net(), realloc_set_internal(), reset(), set(), set_internal(), size(), MIOBuffer::write(), and write_avail().
const char* IOBufferBlock::_location |
Definition at line 497 of file I_IOBuffer.h.
Referenced by alloc(), clone(), new_IOBufferBlock_internal(), and set_internal().
char* IOBufferBlock::_start |
Definition at line 492 of file I_IOBuffer.h.
Referenced by clear(), clone(), consume(), iobufferblock_clone(), iobufferblock_memcpy(), read_avail(), realloc_set_internal(), reset(), set(), set_internal(), size(), start(), and MIOBuffer::write().
The underlying reference to the allocated memory.
A reference to a IOBufferData representing the memory allocated to this buffer. Do not set or modify its value directly.
Definition at line 506 of file I_IOBuffer.h.
Referenced by alloc(), HdrHeap::attach_block(), block_size(), buf(), clear(), clone(), realloc(), reset(), set(), OutgoingControl::set_data(), and set_internal().
Reference to another IOBufferBlock.
A reference to another IOBufferBlock that allows this object to link to other.
Definition at line 513 of file I_IOBuffer.h.
Referenced by UDPPacket::append_block(), MIOBuffer::append_block_internal(), IOBufferReader::block_count(), ClusterState::build_do_io_vector(), ClusterHandler::build_initial_vector(), bytes_IOBufferBlockList(), clear(), clone_IOBufferBlockList(), consume_IOBufferBlockList(), MIOBuffer::current_write_avail(), UDPPacket::getPktLength(), iobufferblock_clone(), iobufferblock_memcpy(), iobufferblock_skip(), IOBufferReader::is_read_avail_more_than(), UnixNetVConnection::load_buffer_and_write(), SSLNetVConnection::load_buffer_and_write(), IOBufferReader::memchr(), IOBufferReader::memcpy(), new_UDPPacket(), IOBufferReader::operator[](), IOBufferReader::read_avail(), read_from_net(), UDPQueue::SendUDPPacket(), ssl_read_from_net(), TSIOBufferBlockNext(), ClusterHandler::valid_for_data_write(), and MIOBuffer::write().