1 /* 2 * Created on Jan 30, 2004 3 * Created by Alon Rohter 4 * Copyright (C) 2004, 2005, 2006 Alon Rohter, All Rights Reserved. 5 * 6 * Copyright (C) Azureus Software, Inc, All Rights Reserved. 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 */ 20 package org.gudy.azureus2.core3.util; 21 22 23 24 public abstract class 25 DirectByteBufferPool 26 { 27 //According to reports (from the http://mina.apache.org folks), hotspot vms actually 28 //work better with non-direct (heap) buffers for network and disk io these days. 29 30 private static final DirectByteBufferPool impl; 31 32 static{ 33 if ( System.getProperty( "use.heap.buffers" ) != null ){ 34 35 // impl = new DirectByteBufferPoolHeap(); 36 37 Debug.outNoStack( "******** USE_HEAP_BUFFERS MODE DEPRECATED ********" ); 38 } 39 40 impl = new DirectByteBufferPoolReal(); 41 } 42 43 44 public static DirectByteBuffer getBuffer( byte allocator, int length )45 getBuffer( 46 byte allocator, 47 int length ) 48 { 49 return( impl.getBufferSupport( allocator, length )); 50 } 51 52 protected abstract DirectByteBuffer getBufferSupport( byte allocator, int length )53 getBufferSupport( 54 byte allocator, 55 int length ); 56 57 protected abstract void returnBufferSupport( DirectByteBuffer buffer )58 returnBufferSupport( 59 DirectByteBuffer buffer ); 60 } 61