Data Structures | Defines | Enumerations | Functions | Variables

I_IOBuffer.h File Reference

I/O classes. More...

#include "libts.h"
#include "ink_resource.h"
Include dependency graph for I_IOBuffer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

class  IOBufferData
 A reference counted wrapper around fast allocated or malloced memory. More...
class  IOBufferBlock
 A linkable portion of IOBufferData. More...
class  IOBufferReader
 An independent reader from an MIOBuffer. More...
class  MIOBuffer
 A multiple reader, single writer memory buffer. More...
struct  MIOBufferAccessor
 A wrapper for either a reader or a writer of an MIOBuffer. More...
class  MIOBuffer_tracker
class  Empty_MIOBuffer_tracker
class  IOBufferBlock_tracker
class  IOBufferData_tracker

Defines

#define TRACK_BUFFER_USER   1
#define DEFAULT_BUFFER_NUMBER   128
#define DEFAULT_HUGE_BUFFER_NUMBER   32
#define MAX_MIOBUFFER_READERS   5
#define DEFAULT_BUFFER_ALIGNMENT   8192
#define DEFAULT_BUFFER_BASE_SIZE   128
#define BUFFER_SIZE_INDEX_128   0
#define BUFFER_SIZE_INDEX_256   1
#define BUFFER_SIZE_INDEX_512   2
#define BUFFER_SIZE_INDEX_1K   3
#define BUFFER_SIZE_INDEX_2K   4
#define BUFFER_SIZE_INDEX_4K   5
#define BUFFER_SIZE_INDEX_8K   6
#define BUFFER_SIZE_INDEX_16K   7
#define BUFFER_SIZE_INDEX_32K   8
#define BUFFER_SIZE_INDEX_64K   9
#define BUFFER_SIZE_INDEX_128K   10
#define BUFFER_SIZE_INDEX_256K   11
#define BUFFER_SIZE_INDEX_512K   12
#define BUFFER_SIZE_INDEX_1M   13
#define BUFFER_SIZE_INDEX_2M   14
#define MAX_BUFFER_SIZE_INDEX   14
#define DEFAULT_BUFFER_SIZES   (MAX_BUFFER_SIZE_INDEX+1)
#define BUFFER_SIZE_FOR_INDEX(_i)   (DEFAULT_BUFFER_BASE_SIZE * (1 << (_i)))
#define DEFAULT_SMALL_BUFFER_SIZE   BUFFER_SIZE_INDEX_512
#define DEFAULT_LARGE_BUFFER_SIZE   BUFFER_SIZE_INDEX_4K
#define DEFAULT_TS_BUFFER_SIZE   BUFFER_SIZE_INDEX_8K
#define DEFAULT_MAX_BUFFER_SIZE   BUFFER_SIZE_FOR_INDEX(MAX_BUFFER_SIZE_INDEX)
#define MIN_IOBUFFER_SIZE   BUFFER_SIZE_INDEX_128
#define MAX_IOBUFFER_SIZE   (DEFAULT_BUFFER_SIZES-1)
#define BUFFER_SIZE_ALLOCATED(_i)
#define BUFFER_SIZE_NOT_ALLOCATED   DEFAULT_BUFFER_SIZES
#define BUFFER_SIZE_INDEX_IS_XMALLOCED(_size_index)   (_size_index < 0)
#define BUFFER_SIZE_INDEX_IS_FAST_ALLOCATED(_size_index)   (((uint64_t)_size_index) < DEFAULT_BUFFER_SIZES)
#define BUFFER_SIZE_INDEX_IS_CONSTANT(_size_index)   (_size_index >= DEFAULT_BUFFER_SIZES)
#define BUFFER_SIZE_FOR_XMALLOC(_size)   (-(_size))
#define BUFFER_SIZE_INDEX_FOR_XMALLOC_SIZE(_size)   (-(_size))
#define BUFFER_SIZE_FOR_CONSTANT(_size)   (_size - DEFAULT_BUFFER_SIZES)
#define BUFFER_SIZE_INDEX_FOR_CONSTANT_SIZE(_size)   (_size+DEFAULT_BUFFER_SIZES)
#define new_MIOBuffer   MIOBuffer_tracker(RES_PATH("memory/IOBuffer/"))
 MIOBuffer allocator/deallocator.
#define new_empty_MIOBuffer   Empty_MIOBuffer_tracker(RES_PATH("memory/IOBuffer/"))
#define new_IOBufferBlock   IOBufferBlock_tracker(RES_PATH("memory/IOBuffer/"))
 IOBufferBlock allocator.
#define new_IOBufferData   IOBufferData_tracker(RES_PATH("memory/IOBuffer/"))
#define new_xmalloc_IOBufferData(b, size)
#define new_constant_IOBufferData(b, size)

Enumerations

enum  AllocType {
  NO_ALLOC, FAST_ALLOCATED, XMALLOCED, MEMALIGNED,
  DEFAULT_ALLOC, CONSTANT
}

Functions

void init_buffer_allocators ()
MIOBuffernew_MIOBuffer_internal (const char *loc, int64_t size_index=default_large_iobuffer_size)
MIOBuffernew_empty_MIOBuffer_internal (const char *loc, int64_t size_index=default_large_iobuffer_size)
void free_MIOBuffer (MIOBuffer *mio)
IOBufferBlocknew_IOBufferBlock_internal (const char *loc)
IOBufferBlocknew_IOBufferBlock_internal (const char *loc, IOBufferData *d, int64_t len=0, int64_t offset=0)
IOBufferDatanew_IOBufferData_internal (const char *location, int64_t size_index=default_large_iobuffer_size, AllocType type=DEFAULT_ALLOC)
IOBufferDatanew_xmalloc_IOBufferData_internal (const char *location, void *b, int64_t size)
IOBufferDatanew_constant_IOBufferData_internal (const char *locaction, void *b, int64_t size)
int64_t iobuffer_size_to_index (int64_t size, int64_t max=max_iobuffer_size)
int64_t index_to_buffer_size (int64_t idx)
IOBufferBlockiobufferblock_clone (IOBufferBlock *b, int64_t offset, int64_t len)
 Clone a IOBufferBlock chain.
IOBufferBlockiobufferblock_skip (IOBufferBlock *b, int64_t *poffset, int64_t *plen, int64_t write)
 Skip over specified bytes in chain.

Variables

inkcoreapi int64_t max_iobuffer_size
int64_t default_small_iobuffer_size
int64_t default_large_iobuffer_size
inkcoreapi Allocator ioBufAllocator [DEFAULT_BUFFER_SIZES]
inkcoreapi ClassAllocator
< IOBufferData
ioDataAllocator
inkcoreapi ClassAllocator
< IOBufferBlock
ioBlockAllocator

Detailed Description

I/O classes.

License

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Watermark

Watermarks can be used as an interface between the data transferring layer (VConnection) and the user layer (a state machine). Watermarks should be used when you need to have at least a certain amount of data to make some determination. For example, when parsing a string, one might wish to ensure that an entire line will come in before consuming the data. In such a case, the water_mark should be set to the largest possible size of the string. (appropriate error handling should take care of exessively long strings).

In all other cases, especially when all data will be consumed, the water_mark should be set to 0 (the default).

Definition in file I_IOBuffer.h.


Define Documentation

#define BUFFER_SIZE_ALLOCATED (   _i  ) 
#define BUFFER_SIZE_FOR_CONSTANT (   _size  )     (_size - DEFAULT_BUFFER_SIZES)

Definition at line 129 of file I_IOBuffer.h.

Referenced by index_to_buffer_size().

#define BUFFER_SIZE_FOR_INDEX (   _i  )     (DEFAULT_BUFFER_BASE_SIZE * (1 << (_i)))
#define BUFFER_SIZE_FOR_XMALLOC (   _size  )     (-(_size))
#define BUFFER_SIZE_INDEX_128   0

Definition at line 88 of file I_IOBuffer.h.

#define BUFFER_SIZE_INDEX_128K   10

Definition at line 98 of file I_IOBuffer.h.

#define BUFFER_SIZE_INDEX_16K   7

Definition at line 95 of file I_IOBuffer.h.

#define BUFFER_SIZE_INDEX_1K   3

Definition at line 91 of file I_IOBuffer.h.

#define BUFFER_SIZE_INDEX_1M   13

Definition at line 101 of file I_IOBuffer.h.

#define BUFFER_SIZE_INDEX_256   1

Definition at line 89 of file I_IOBuffer.h.

Referenced by ChunkedHandler::init_by_action().

#define BUFFER_SIZE_INDEX_256K   11

Definition at line 99 of file I_IOBuffer.h.

#define BUFFER_SIZE_INDEX_2K   4

Definition at line 92 of file I_IOBuffer.h.

#define BUFFER_SIZE_INDEX_2M   14

Definition at line 102 of file I_IOBuffer.h.

#define BUFFER_SIZE_INDEX_32K   8
#define BUFFER_SIZE_INDEX_4K   5

Definition at line 93 of file I_IOBuffer.h.

#define BUFFER_SIZE_INDEX_512   2

Definition at line 90 of file I_IOBuffer.h.

Referenced by Cache::link().

#define BUFFER_SIZE_INDEX_512K   12

Definition at line 100 of file I_IOBuffer.h.

#define BUFFER_SIZE_INDEX_64K   9

Definition at line 97 of file I_IOBuffer.h.

#define BUFFER_SIZE_INDEX_8K   6

Definition at line 94 of file I_IOBuffer.h.

#define BUFFER_SIZE_INDEX_FOR_CONSTANT_SIZE (   _size  )     (_size+DEFAULT_BUFFER_SIZES)

Definition at line 130 of file I_IOBuffer.h.

Referenced by new_constant_IOBufferData_internal(), and MIOBuffer::set().

#define BUFFER_SIZE_INDEX_FOR_XMALLOC_SIZE (   _size  )     (-(_size))
#define BUFFER_SIZE_INDEX_IS_CONSTANT (   _size_index  )     (_size_index >= DEFAULT_BUFFER_SIZES)

Definition at line 123 of file I_IOBuffer.h.

Referenced by index_to_buffer_size(), and new_IOBufferData_internal().

#define BUFFER_SIZE_INDEX_IS_FAST_ALLOCATED (   _size_index  )     (((uint64_t)_size_index) < DEFAULT_BUFFER_SIZES)

Definition at line 121 of file I_IOBuffer.h.

Referenced by IOBufferData::alloc(), IOBufferData::dealloc(), and index_to_buffer_size().

#define BUFFER_SIZE_INDEX_IS_XMALLOCED (   _size_index  )     (_size_index < 0)

Definition at line 120 of file I_IOBuffer.h.

Referenced by IOBufferData::alloc(), IOBufferData::dealloc(), and index_to_buffer_size().

#define BUFFER_SIZE_NOT_ALLOCATED   DEFAULT_BUFFER_SIZES

Definition at line 119 of file I_IOBuffer.h.

Referenced by IOBufferBlock::realloc(), and IOBufferBlock::set_internal().

#define DEFAULT_BUFFER_ALIGNMENT   8192

Definition at line 79 of file I_IOBuffer.h.

#define DEFAULT_BUFFER_BASE_SIZE   128

Definition at line 80 of file I_IOBuffer.h.

Referenced by init_buffer_allocators().

#define DEFAULT_BUFFER_NUMBER   128

Definition at line 75 of file I_IOBuffer.h.

Referenced by init_buffer_allocators().

#define DEFAULT_BUFFER_SIZES   (MAX_BUFFER_SIZE_INDEX+1)

Definition at line 104 of file I_IOBuffer.h.

Referenced by ClusterProcessor::free_remote_data(), ink_event_system_init(), and main().

#define DEFAULT_HUGE_BUFFER_NUMBER   32

Definition at line 77 of file I_IOBuffer.h.

#define DEFAULT_LARGE_BUFFER_SIZE   BUFFER_SIZE_INDEX_4K

Definition at line 108 of file I_IOBuffer.h.

#define DEFAULT_MAX_BUFFER_SIZE   BUFFER_SIZE_FOR_INDEX(MAX_BUFFER_SIZE_INDEX)
#define DEFAULT_SMALL_BUFFER_SIZE   BUFFER_SIZE_INDEX_512

Definition at line 107 of file I_IOBuffer.h.

#define DEFAULT_TS_BUFFER_SIZE   BUFFER_SIZE_INDEX_8K

Definition at line 109 of file I_IOBuffer.h.

#define MAX_BUFFER_SIZE_INDEX   14
#define MAX_IOBUFFER_SIZE   (DEFAULT_BUFFER_SIZES-1)

Definition at line 112 of file I_IOBuffer.h.

Referenced by ClusterHandler::dump_internal_data().

#define MAX_MIOBUFFER_READERS   5

Definition at line 78 of file I_IOBuffer.h.

#define MIN_IOBUFFER_SIZE   BUFFER_SIZE_INDEX_128

Definition at line 111 of file I_IOBuffer.h.

#define new_constant_IOBufferData (   b,
  size 
)
Value:
new_constant_IOBufferData_internal(RES_PATH("memory/IOBuffer/"), \
                                  (b), (size))

Definition at line 1342 of file I_IOBuffer.h.

Referenced by ClusterHandler::build_data_vector(), and ClusterHandler::build_initial_vector().

#define new_empty_MIOBuffer   Empty_MIOBuffer_tracker(RES_PATH("memory/IOBuffer/"))
#define new_IOBufferBlock   IOBufferBlock_tracker(RES_PATH("memory/IOBuffer/"))
#define new_IOBufferData   IOBufferData_tracker(RES_PATH("memory/IOBuffer/"))
#define new_MIOBuffer   MIOBuffer_tracker(RES_PATH("memory/IOBuffer/"))

MIOBuffer allocator/deallocator.

Definition at line 1253 of file I_IOBuffer.h.

Referenced by HttpTunnel::allocate_redirect_postdata_buffers(), HttpTunnel::allocate_redirect_postdata_producer_buffer(), TestProxy::cacheSendGetEvent(), TestProxy::connectEvent(), HttpSM::do_setup_post_tunnel(), TransformControl::handle_event(), ObjectReloadCont::Init(), SocksProxy::init(), SocksEntry::init(), KeepAliveConn::init(), PrefetchBlaster::init(), PluginVCCore::init(), OneWayTunnel::init(), OneWayMultiTunnel::init(), ChunkedHandler::init_by_action(), FetchSM::init_comm(), NetTesterSM::NetTesterSM(), HttpServerSession::new_connection(), HttpClientSession::new_connection(), Http2ClientSession::new_connection(), ObjectReloadCont::ObjectReloadEvent(), ProtocolProbeTrampoline::ProtocolProbeTrampoline(), redirect_test(), HttpSM::setup_100_continue_transfer(), HttpSM::setup_blind_tunnel(), HttpSM::setup_cache_read_transfer(), HttpSM::setup_cache_transfer_to_transform(), setup_client_request(), HttpSM::setup_internal_transfer(), HttpSM::setup_push_transfer_to_cache(), HttpSM::setup_server_send_request(), HttpSM::setup_server_transfer(), HttpSM::setup_server_transfer_to_cache_only(), HttpSM::setup_server_transfer_to_transform(), HttpSM::setup_transfer_from_transform(), HttpSM::setup_transfer_from_transform_to_cache_only(), HttpSM::setup_transform_to_server_transfer(), CacheContinuation::setupVCdataRead(), NetVCTest::start_test(), TestAccept::startEvent(), HttpSM::state_send_server_request_header(), TSIOBufferSizedCreate(), and PrefetchUrlBlaster::udpUrlBlaster().

#define new_xmalloc_IOBufferData (   b,
  size 
)
#define TRACK_BUFFER_USER   1

Enumeration Type Documentation

enum AllocType
Enumerator:
NO_ALLOC 
FAST_ALLOCATED 
XMALLOCED 
MEMALIGNED 
DEFAULT_ALLOC 
CONSTANT 

Definition at line 62 of file I_IOBuffer.h.


Function Documentation

void free_MIOBuffer ( MIOBuffer mio  ) 
int64_t index_to_buffer_size ( int64_t  idx  ) 
void init_buffer_allocators (  ) 
int64_t iobuffer_size_to_index ( int64_t  size,
int64_t  max = max_iobuffer_size 
)
IOBufferBlock* iobufferblock_clone ( IOBufferBlock b,
int64_t  offset,
int64_t  len 
)

Clone a IOBufferBlock chain.

Used to snarf a IOBufferBlock chain w/o copy.

Parameters:
b head of source IOBufferBlock chain.
offset # bytes in the beginning to skip.
len bytes to copy from source.
Returns:
ptr to head of new IOBufferBlock chain.

Definition at line 75 of file P_IOBuffer.h.

References IOBufferBlock::_buf_end, IOBufferBlock::_end, IOBufferBlock::_start, IOBufferBlock::clone(), IOBufferBlock::next, and start.

Referenced by CacheVC::openReadFromWriterMain().

IOBufferBlock* iobufferblock_skip ( IOBufferBlock b,
int64_t *  poffset,
int64_t *  plen,
int64_t  write 
)

Skip over specified bytes in chain.

Used for dropping references.

Parameters:
b head of source IOBufferBlock chain.
poffset originally offset in b, finally offset in returned IOBufferBlock.
plen value of write is subtracted from plen in the function.
write bytes to skip.
Returns:
ptr to head of new IOBufferBlock chain.

Definition at line 112 of file P_IOBuffer.h.

References IOBufferBlock::next, and IOBufferBlock::read_avail().

Referenced by CacheVC::openReadFromWriterMain(), CacheVC::openWriteCloseDataDone(), and CacheVC::openWriteWriteDone().

IOBufferData* new_constant_IOBufferData_internal ( const char *  locaction,
void *  b,
int64_t  size 
)
MIOBuffer* new_empty_MIOBuffer_internal ( const char *  loc,
int64_t  size_index = default_large_iobuffer_size 
)
IOBufferBlock* new_IOBufferBlock_internal ( const char *  loc,
IOBufferData d,
int64_t  len = 0,
int64_t  offset = 0 
)
IOBufferBlock* new_IOBufferBlock_internal ( const char *  loc  ) 
IOBufferData* new_IOBufferData_internal ( const char *  location,
int64_t  size_index = default_large_iobuffer_size,
AllocType  type = DEFAULT_ALLOC 
)
MIOBuffer* new_MIOBuffer_internal ( const char *  loc,
int64_t  size_index = default_large_iobuffer_size 
)
IOBufferData* new_xmalloc_IOBufferData_internal ( const char *  location,
void *  b,
int64_t  size 
)

Variable Documentation

Definition at line 38 of file IOBuffer.cc.

Referenced by ink_event_system_init(), and main().

inkcoreapi ClassAllocator<IOBufferBlock> ioBlockAllocator
inkcoreapi Allocator ioBufAllocator[DEFAULT_BUFFER_SIZES]
inkcoreapi ClassAllocator<IOBufferData> ioDataAllocator
inkcoreapi int64_t max_iobuffer_size