// ************************************************************************ // $Id: LTPrivateMemory.java 561 2005-07-11 20:09:17Z mdeters $ // ************************************************************************ // // jRate // // Copyright (C) 2001-2005 by Angelo Corsaro. // // All Rights Reserved. // // Permission to use, copy, modify, and distribute this software and // its documentation for any purpose is hereby granted without fee, // provided that the above copyright notice appear in all copies and // that both that copyright notice and this permission notice appear // in supporting documentation. I don't make any representations // about the suitability of this software for any purpose. It is // provided "as is" without express or implied warranty. // // // ************************************************************************* // // ************************************************************************* package javax.realtime; /** * The LTPrivateMemory provides linear time allocation * time. This type of scoped memory allows only one thread at the time * to be within it. Thus it can be considered as a thread * private memory. If more than one thread try to access it at * the same time a run-time exception is thrown. * * @author Angelo Corsaro * @version 1.0 */ public class LTPrivateMemory extends PrivateScopedMemory { /** * Creates a new LTPrivateMemory instance. * * @param minSize a long value representing the * minimum size for this memory. * @param maxSize a long value representing the max * size for this memory area. */ public LTPrivateMemory(long minSize, long maxSize) { this(maxSize, null); } /** * Creates a new LTPrivateMemory instance. * * @param size The size of MemoryArea to allocate, in * bytes. If size is less than or equal to zero an * {@link IllegalArgumentException} is thrown. */ public LTPrivateMemory(long size) { this(size, null); } /** * Creates a new LTPrivateMemory instance. * * @param size The size of MemoryArea to allocate, in * bytes. If size is less than or equal to zero an * {@link IllegalArgumentException} is thrown. * @param logic -The java.lang.Runnable whose run() method is * invoked when any of the variations of enter() which do not take * a java.lang.Runnable is called. */ public LTPrivateMemory(long size, Runnable logic) { super(size, logic); } /** * Creates a new LTPrivateMemory instance. * * @param size A {@link SizeEstimator} object which indicates the * amount of memory required by this MemoryArea. */ public LTPrivateMemory(SizeEstimator size) { this(size.getEstimate(), null); } /** * Creates a new LTPrivateMemory instance. * * @param size The size of MemoryArea to * allocate, in bytes. * @param logic The run() method of this object will be called * whenever enter() called. */ public LTPrivateMemory(SizeEstimator size, Runnable logic) { this(size.getEstimate(), logic); } /** * An exact count, in bytes, of the all of the memory currently * used by the system for the allocated objects. * * @return The amount of memory consumed in bytes. */ public native long memoryConsumed(); /** * An approximation to the total amount of memory currently * available for future allocated objects, measured in bytes. * * @return The amount of remaining memory in bytes. */ public native long memoryRemaining(); // -- Native Methods -- protected native void init(); protected native void fini(); }