2012-11-15 22:04:37 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2012 The Netty Project
|
|
|
|
*
|
|
|
|
* The Netty Project 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.
|
|
|
|
*/
|
|
|
|
package io.netty.buffer;
|
|
|
|
|
2013-02-17 20:12:48 +01:00
|
|
|
/**
|
|
|
|
* Implementations are responsible to allocate buffers. Implementations of this interface are expected to be
|
|
|
|
* thread-safe.
|
|
|
|
*/
|
2012-11-15 22:04:37 +01:00
|
|
|
public interface ByteBufAllocator {
|
|
|
|
|
2013-02-17 20:12:48 +01:00
|
|
|
/**
|
|
|
|
* Allocate a {@link ByteBuf}. If it is a direct or heap buffer
|
|
|
|
* depends on the actual implementation.
|
|
|
|
*/
|
2012-11-15 22:04:37 +01:00
|
|
|
ByteBuf buffer();
|
2013-02-17 20:12:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocate a {@link ByteBuf} with the given initial capacity.
|
|
|
|
* If it is a direct or heap buffer depends on the actual implementation.
|
|
|
|
*/
|
2012-11-15 22:04:37 +01:00
|
|
|
ByteBuf buffer(int initialCapacity);
|
2013-02-17 20:12:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocate a {@link ByteBuf} with the given initial capacity and the given
|
|
|
|
* maximal capacity. If it is a direct or heap buffer depends on the actual
|
|
|
|
* implementation.
|
|
|
|
*/
|
2012-11-15 22:04:37 +01:00
|
|
|
ByteBuf buffer(int initialCapacity, int maxCapacity);
|
2013-02-17 20:12:48 +01:00
|
|
|
|
2013-03-05 09:59:31 +01:00
|
|
|
/**
|
|
|
|
* Allocate a {@link ByteBuf} whose initial capacity is 0, preferably a direct buffer which is suitable for I/O.
|
|
|
|
*/
|
|
|
|
ByteBuf ioBuffer();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocate a {@link ByteBuf}, preferably a direct buffer which is suitable for I/O.
|
|
|
|
*/
|
|
|
|
ByteBuf ioBuffer(int initialCapacity);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocate a {@link ByteBuf}, preferably a direct buffer which is suitable for I/O.
|
|
|
|
*/
|
|
|
|
ByteBuf ioBuffer(int initialCapacity, int maxCapacity);
|
|
|
|
|
2013-02-17 20:12:48 +01:00
|
|
|
/**
|
|
|
|
* Allocate a heap {@link ByteBuf}.
|
|
|
|
*/
|
2012-11-15 22:04:37 +01:00
|
|
|
ByteBuf heapBuffer();
|
2013-02-17 20:12:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocate a heap {@link ByteBuf} with the given initial capacity.
|
|
|
|
*/
|
2012-11-15 22:04:37 +01:00
|
|
|
ByteBuf heapBuffer(int initialCapacity);
|
2013-02-17 20:12:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocate a heap {@link ByteBuf} with the given initial capacity and the given
|
|
|
|
* maximal capacity.
|
|
|
|
*/
|
2012-11-15 22:04:37 +01:00
|
|
|
ByteBuf heapBuffer(int initialCapacity, int maxCapacity);
|
2013-02-17 20:12:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocate a direct {@link ByteBuf}.
|
|
|
|
*/
|
2012-11-15 22:04:37 +01:00
|
|
|
ByteBuf directBuffer();
|
2013-02-17 20:12:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocate a direct {@link ByteBuf} with the given initial capacity.
|
|
|
|
*/
|
2012-11-15 22:04:37 +01:00
|
|
|
ByteBuf directBuffer(int initialCapacity);
|
2013-02-17 20:12:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocate a direct {@link ByteBuf} with the given initial capacity and the given
|
|
|
|
* maximal capacity.
|
|
|
|
*/
|
2012-11-15 22:04:37 +01:00
|
|
|
ByteBuf directBuffer(int initialCapacity, int maxCapacity);
|
2013-02-17 20:12:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocate a {@link CompositeByteBuf}.
|
|
|
|
* If it is a direct or heap buffer depends on the actual implementation.
|
|
|
|
*/
|
2012-12-05 22:11:48 +01:00
|
|
|
CompositeByteBuf compositeBuffer();
|
2013-02-17 20:12:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocate a {@link CompositeByteBuf} with the given maximum number of components that can be stored in it.
|
|
|
|
* If it is a direct or heap buffer depends on the actual implementation.
|
|
|
|
*/
|
2012-12-05 22:11:48 +01:00
|
|
|
CompositeByteBuf compositeBuffer(int maxNumComponents);
|
2013-02-17 20:12:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocate a heap {@link CompositeByteBuf}.
|
|
|
|
*/
|
2012-12-05 22:11:48 +01:00
|
|
|
CompositeByteBuf compositeHeapBuffer();
|
2013-02-17 20:12:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocate a heap {@link CompositeByteBuf} with the given maximum number of components that can be stored in it.
|
|
|
|
*/
|
2012-12-05 22:11:48 +01:00
|
|
|
CompositeByteBuf compositeHeapBuffer(int maxNumComponents);
|
2013-02-17 20:12:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocate a direct {@link CompositeByteBuf}.
|
|
|
|
*/
|
2012-12-05 22:11:48 +01:00
|
|
|
CompositeByteBuf compositeDirectBuffer();
|
2013-02-17 20:12:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocate a direct {@link CompositeByteBuf} with the given maximum number of components that can be stored in it.
|
|
|
|
*/
|
2012-12-05 22:11:48 +01:00
|
|
|
CompositeByteBuf compositeDirectBuffer(int maxNumComponents);
|
2012-11-15 22:04:37 +01:00
|
|
|
}
|