Modify the WindowedFile API to pass around a WindowCursor during reads
commit2a8dfd1ec45edcd49dd10ccc4ce55c604274b257
authorShawn O. Pearce <spearce@spearce.org>
Thu, 6 Mar 2008 09:00:37 +0000 (6 04:00 -0500)
committerShawn O. Pearce <spearce@spearce.org>
Mon, 7 Apr 2008 03:40:30 +0000 (6 23:40 -0400)
tree59f64a1d4c68a91a1ff48cb5ce8fc8278ebb124c
parentda821e22e6514f1ddfdd2df1297d98b06ccb91c2
Modify the WindowedFile API to pass around a WindowCursor during reads

By passing a WindowCursor object that is "stack allocated" by the
caller we can store temporary metadata necessary to perform any
read operation, and have that metadata clear out when the caller
returns from their stack frame and pops the only reference to the
WindowCursor object they created for the read operation.

Its not immediately obvious yet but the idea behind this cursor is
to allow storage of both the ByteWindow and the underlying data it
relies upon, but to do so using only strongly held references.  We
can then transition the WindowCache to use SoftReferences to retain
the bulky internal data of a ByteWindow and let the JVM's GC decide
when it needs to make Git drop memory out of the cache because the
available heap space has run low.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
org.spearce.jgit/src/org/spearce/jgit/lib/ByteArrayWindow.java
org.spearce.jgit/src/org/spearce/jgit/lib/ByteWindow.java
org.spearce.jgit/src/org/spearce/jgit/lib/PackFile.java
org.spearce.jgit/src/org/spearce/jgit/lib/WindowCache.java
org.spearce.jgit/src/org/spearce/jgit/lib/WindowCursor.java [new file with mode: 0644]
org.spearce.jgit/src/org/spearce/jgit/lib/WindowProvider.java
org.spearce.jgit/src/org/spearce/jgit/lib/WindowedFile.java