/* * Copyright (c) 2012 the original author or authors. * * Licensed 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 org.eclipse.jetty.spdy; import java.nio.ByteBuffer; /** * <p>A {@link ByteBuffer} pool.</p> * <p>Acquired buffers may be {@link #release(ByteBuffer) released} but they do not need to; * if they are released, they may be recycled and reused, otherwise they will be garbage * collected as usual.</p> */ public interface ByteBufferPool { /** * <p>Requests a {@link ByteBuffer} of the given size.</p> * <p>The returned buffer may have a bigger capacity than the size being * requested but it will have the limit set to the given size.</p> * * @param size the size of the buffer * @param direct whether the buffer must be direct or not * @return the requested buffer * @see #release(ByteBuffer) */ public ByteBuffer acquire(int size, boolean direct); /** * <p>Returns a {@link ByteBuffer}, usually obtained with {@link #acquire(int, boolean)} * (but not necessarily), making it available for recycling and reuse.</p> * * @param buffer the buffer to return * @see #acquire(int, boolean) */ public void release(ByteBuffer buffer); }