X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=lib%2Fjetty%2Forg%2Feclipse%2Fjetty%2Fio%2FByteBufferPool.java;fp=lib%2Fjetty%2Forg%2Feclipse%2Fjetty%2Fio%2FByteBufferPool.java;h=302adde35d879be5795b727ec8f47140bae5a352;hp=0000000000000000000000000000000000000000;hb=73ef54a38e3930a1a789cdc6b5fa23cdd4c9d086;hpb=515007c7c1351045420669d65b59c08fa46850f2 diff --git a/lib/jetty/org/eclipse/jetty/io/ByteBufferPool.java b/lib/jetty/org/eclipse/jetty/io/ByteBufferPool.java new file mode 100644 index 00000000..302adde3 --- /dev/null +++ b/lib/jetty/org/eclipse/jetty/io/ByteBufferPool.java @@ -0,0 +1,51 @@ +// +// ======================================================================== +// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package org.eclipse.jetty.io; + +import java.nio.ByteBuffer; + +/** + *

A {@link ByteBuffer} pool.

+ *

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.

+ */ +public interface ByteBufferPool +{ + /** + *

Requests a {@link ByteBuffer} of the given size.

+ *

The returned buffer may have a bigger capacity than the size being + * requested but it will have the limit set to the given size.

+ * + * @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); + + /** + *

Returns a {@link ByteBuffer}, usually obtained with {@link #acquire(int, boolean)} + * (but not necessarily), making it available for recycling and reuse.

+ * + * @param buffer the buffer to return + * @see #acquire(int, boolean) + */ + public void release(ByteBuffer buffer); +}