harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r423852 - in /incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java: java/nio/DirectByteBuffer.java java/nio/MappedByteBuffer.java java/nio/MappedByteBufferAdapter.java org/apache/harmony/nio/internal/FileChannelImpl.java
Date Thu, 20 Jul 2006 09:31:45 GMT
Author: pyang
Date: Thu Jul 20 02:31:44 2006
New Revision: 423852

URL: http://svn.apache.org/viewvc?rev=423852&view=rev
Log:
Refactor the mmap related functions:
1. add MappedPlatformAddress as subclass of PlatformAddress, which is used by MappedByteBuffer,
move the mmap related functions out of PlatformAddress to MappedPlatformAddress
2. add size parameter to IMemorySystem.unmap(), fix the memory leak problem on Linux
3. add size field to PlatformAddress to simplify AbstractMemorySpy
3. refactor the parameter of IMemorySystem's mmap related functions, change PlatformAddress
to primitive long to keep consistency with other functions
4. other minor changes to fix some potential bugs

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/DirectByteBuffer.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBuffer.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBufferAdapter.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/DirectByteBuffer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/DirectByteBuffer.java?rev=423852&r1=423851&r2=423852&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/DirectByteBuffer.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/DirectByteBuffer.java
Thu Jul 20 02:31:44 2006
@@ -16,6 +16,7 @@
 package java.nio;
 
 import org.apache.harmony.luni.platform.PlatformAddress;
+import org.apache.harmony.luni.platform.PlatformAddressFactory;
 import org.apache.harmony.nio.internal.DirectBuffer;
 
 
@@ -60,7 +61,7 @@
      * encouraged to explicitly free the memory where possible.
      */
 	DirectByteBuffer(int capacity) {
-		this(new SafeAddress(PlatformAddress.alloc(capacity, (byte)0)), capacity, 0);
+		this(new SafeAddress(PlatformAddressFactory.alloc(capacity, (byte)0)), capacity, 0);
 		safeAddress.address.autoFree();
 	}
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBuffer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBuffer.java?rev=423852&r1=423851&r2=423852&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBuffer.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBuffer.java
Thu Jul 20 02:31:44 2006
@@ -16,6 +16,7 @@
 package java.nio;
 
 import org.apache.harmony.luni.platform.IMemorySystem;
+import org.apache.harmony.luni.platform.MappedPlatformAddress;
 import org.apache.harmony.luni.platform.PlatformAddress;
 import org.apache.harmony.nio.internal.DirectBuffer;
 
@@ -75,8 +76,7 @@
 	 * @return True if this buffer's content is loaded.
 	 */
 	public final boolean isLoaded() {
-		return ((DirectBuffer) wrapped).getEffectiveAddress().mmapIsLoaded(
-                wrapped.capacity());
+		return ((MappedPlatformAddress)((DirectBuffer) wrapped).getBaseAddress()).mmapIsLoaded();
 	}
 
 	/**
@@ -85,8 +85,7 @@
 	 * @return This buffer
 	 */
 	public final MappedByteBuffer load() {
-		((DirectBuffer) wrapped).getEffectiveAddress().mmapLoad(
-                wrapped.capacity());
+		((MappedPlatformAddress)((DirectBuffer) wrapped).getBaseAddress()).mmapLoad();
 		return this;
 	}
 
@@ -100,8 +99,7 @@
      */
     public final MappedByteBuffer force() {
         if (mapMode == IMemorySystem.MMAP_READ_WRITE) {
-            ((DirectBuffer) wrapped).getEffectiveAddress().mmapFlush(
-                    wrapped.capacity());
+            ((MappedPlatformAddress)((DirectBuffer) wrapped).getBaseAddress()).mmapFlush();
         }
         return this;
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBufferAdapter.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBufferAdapter.java?rev=423852&r1=423851&r2=423852&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBufferAdapter.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBufferAdapter.java
Thu Jul 20 02:31:44 2006
@@ -15,6 +15,7 @@
 
 package java.nio;
 
+import org.apache.harmony.luni.platform.MappedPlatformAddress;
 import org.apache.harmony.luni.platform.PlatformAddress;
 import org.apache.harmony.nio.internal.DirectBuffer;
 
@@ -354,7 +355,7 @@
 	}
 
 	public void free() {
-		this.wrapped.getBaseAddress().unmap();
+		((MappedPlatformAddress)this.wrapped.getBaseAddress()).free();
 		this.wrapped.free();
 	}
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java?rev=423852&r1=423851&r2=423852&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java
Thu Jul 20 02:31:44 2006
@@ -23,15 +23,14 @@
 import java.nio.channels.ClosedChannelException;
 import java.nio.channels.FileChannel;
 import java.nio.channels.FileLock;
-import java.nio.channels.NonReadableChannelException;
 import java.nio.channels.NonWritableChannelException;
 import java.nio.channels.ReadableByteChannel;
 import java.nio.channels.WritableByteChannel;
 
 import org.apache.harmony.luni.platform.IFileSystem;
-import org.apache.harmony.luni.platform.IMemorySystem;
 import org.apache.harmony.luni.platform.Platform;
 import org.apache.harmony.luni.platform.PlatformAddress;
+import org.apache.harmony.luni.platform.PlatformAddressFactory;
 
 /*
  * The file channel impl class is the bridge between the logical channels
@@ -46,9 +45,6 @@
 	// Reference to the portable file system code.
 	private static final IFileSystem fileSystem = Platform.getFileSystem();
 
-    private static final IMemorySystem memorySystem = Platform
-            .getMemorySystem();
-
     private static final int NATIVE_PAGE_SIZE;
 
     static {
@@ -195,7 +191,7 @@
         }
         long alignment = position - position % NATIVE_PAGE_SIZE;
         int offset = (int) (position - alignment);
-        PlatformAddress address = memorySystem.mmap(handle, alignment, size
+        PlatformAddress address = PlatformAddressFactory.allocMap(handle, alignment, size
                 + offset, mapMode);
         MappedByteBuffer buffer = null;
         try {



Mime
View raw message