001    // ImmortalMemory.java, created by wbeebee
002    // Copyright (C) 2001 Wes Beebee <wbeebee@mit.edu>
003    // Licensed under the terms of the GNU GPL; see COPYING for details.
004    package javax.realtime;
005    
006    /**
007     * @author Wes Beebee <<a href="mailto:wbeebee@mit.edu">wbeebee@mit.edu</a>>
008     */
009    
010    /** <code>ImmortalMemory</code> is a memory resource that is shared among
011     *  all threads. Objects allocated in the immortal memory live until the
012     *  end of the application. Objects in immoral memory are nver subjected
013     *  to garbage collection, although some GC algorithms may require a scan
014     *  of the immortal memory. An immortal object may only contain reference
015     *  to other immortal objects or to heap objects. Unlike standard Java
016     *  heap objects, immoratl objects continue to exist even after there are
017     *  no other references to them.
018     */
019    public /* specs says it's final */ class ImmortalMemory extends MemoryArea {
020        private static ImmortalMemory immortalMemory;
021       
022        /* Don't use this! */
023        public ImmortalMemory() {
024            super(1000000000); // Totally bogus
025        }
026    
027        /** Returns a pointer to the singleton <code>ImmortalMemory</code> space.
028         *
029         *  @return The singleton <code>ImmortalMemory</code> object.
030         */
031        public static ImmortalMemory instance() {
032            if (immortalMemory == null) {
033                immortalMemory = (ImmortalMemory)((new ImmortalMemory()).shadow);
034                immortalMemory.shadow = immortalMemory.memoryArea = immortalMemory;
035            }
036            return immortalMemory;
037        }
038    
039        protected native void initNative(long sizeInBytes);
040        
041        public String toString() {
042            return "ImmortalMemory: " + super.toString();
043        }
044    }