KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xsocket > stream > io > impl > IMemoryManager


1 // $Id: IMemoryManager.java 1304 2007-06-02 13:26:34Z grro $
2
/*
3  * Copyright (c) xsocket.org, 2006 - 2007. All rights reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Please refer to the LGPL license at: http://www.gnu.org/copyleft/lesser.txt
20  * The latest copy of this software may be found on http://www.xsocket.org/
21  */

22 package org.xsocket.stream.io.impl;
23
24 import java.nio.ByteBuffer JavaDoc;
25
26
27 /**
28  * memory manager
29  *
30  * @author grro
31  */

32 interface IMemoryManager {
33     
34     
35     /**
36      * acquire ByteBuffer with free memory
37      *
38      * @return the ByteBuffer with free memory
39      */

40     public ByteBuffer JavaDoc acquireMemory(int minSize);
41     
42     
43     /**
44      * recycle a ByteBuffer (if remaining larger than min size)
45      *
46      * @param buffer the ByteBuffer to recycle
47      * @param minSize the min preallocated size
48      */

49     public void recycleMemory(ByteBuffer JavaDoc buffer, int minSize);
50
51     
52     /**
53      * preallocate, if preallocated size is smaller the given minSize
54      *
55      * @param minSize the min preallocated size
56      */

57     public void preallocate(int minSize);
58
59     
60     
61     /**
62      * get the current free preallocated buffer size
63      * @return the current free preallocated buffe size
64      */

65     public int getFreeBufferSize();
66 }
67
Popular Tags