Author: mturk
Date: Fri Dec  4 08:01:49 2009
New Revision: 887092

URL: http://svn.apache.org/viewvc?rev=887092&view=rev
Log:
Avoid needles callbacks into JVM

Modified:
    
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java
    
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Semaphore.java
    
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SharedMemory.java
    commons/sandbox/runtime/trunk/src/main/native/shared/mutex.c
    commons/sandbox/runtime/trunk/src/main/native/shared/sema.c
    commons/sandbox/runtime/trunk/src/main/native/shared/shm.c

Modified: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java?rev=887092&r1=887091&r2=887092&view=diff
==============================================================================
--- 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java
 Fri Dec  4 08:01:49 2009
@@ -117,7 +117,7 @@
         }
     }
 
-    public static native void lock0(Descriptor sem)
+    public static native void lock0(int sem)
         throws IOException, SecurityException;
     /**
      * Acquire the lock for {...@code this} Mutex.
@@ -128,14 +128,14 @@
         throws IOException, SecurityException, ClosedDescriptorException
     {
         if (mutex.valid()) {
-            lock0(mutex);
+            lock0(mutex.fd());
         }
         else {
             throw new ClosedDescriptorException();
         }
     }
 
-    public static native boolean lock1(Descriptor sem)
+    public static native boolean lock1(int sem)
         throws IOException, SecurityException;
     /**
      * Attempt to acquire the lock for {...@code this} Mutex.
@@ -146,14 +146,14 @@
         throws IOException, SecurityException, ClosedDescriptorException
     {
         if (mutex.valid()) {
-            return lock1(mutex);
+            return lock1(mutex.fd());
         }
         else {
             throw new ClosedDescriptorException();
         }
     }
 
-    public static native void release0(Descriptor sem)
+    public static native void release0(int sem)
         throws IOException, SecurityException;
     /**
      * Release the lock for {...@code this} Mutex.
@@ -162,7 +162,7 @@
         throws IOException, SecurityException, ClosedDescriptorException
     {
         if (mutex.valid()) {
-            release0(mutex);
+            release0(mutex.fd());
         }
         else {
             throw new ClosedDescriptorException();

Modified: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Semaphore.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Semaphore.java?rev=887092&r1=887091&r2=887092&view=diff
==============================================================================
--- 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Semaphore.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Semaphore.java
 Fri Dec  4 08:01:49 2009
@@ -141,7 +141,7 @@
         }
     }
 
-    public static native void wait0(Descriptor sem)
+    public static native void wait0(int sem)
         throws IOException, SecurityException;
     /**
      * Acquire the lock for the given semaphore.
@@ -152,14 +152,14 @@
         throws IOException, SecurityException, ClosedDescriptorException
     {
         if (sem.valid()) {
-            wait0(sem);
+            wait0(sem.fd());
         }
         else {
             throw new ClosedDescriptorException();
         }
     }
 
-    public static native boolean wait1(Descriptor sem)
+    public static native boolean wait1(int sem)
         throws IOException, SecurityException;
     /**
      * Attempt to acquire the lock for the given semaphore.
@@ -170,14 +170,14 @@
         throws IOException, SecurityException, ClosedDescriptorException
     {
         if (sem.valid()) {
-            return wait1(sem);
+            return wait1(sem.fd());
         }
         else {
             throw new ClosedDescriptorException();
         }
     }
 
-    public static native void release0(Descriptor sem)
+    public static native void release0(int sem)
         throws IOException, SecurityException;
     /**
      * Release the lock for the given semaphore.
@@ -186,14 +186,14 @@
         throws IOException, SecurityException, ClosedDescriptorException
     {
         if (sem.valid()) {
-            release0(sem);
+            release0(sem.fd());
         }
         else {
             throw new ClosedDescriptorException();
         }
     }
 
-    public static native void release1(Descriptor sem)
+    public static native void release1(int sem)
         throws IOException, SecurityException;
     /**
      * Reset the given semaphore.
@@ -202,7 +202,7 @@
         throws IOException, SecurityException, ClosedDescriptorException
     {
         if (sem.valid()) {
-            release1(sem);
+            release1(sem.fd());
         }
         else {
             throw new ClosedDescriptorException();

Modified: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SharedMemory.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SharedMemory.java?rev=887092&r1=887091&r2=887092&view=diff
==============================================================================
--- 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SharedMemory.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SharedMemory.java
 Fri Dec  4 08:01:49 2009
@@ -227,7 +227,7 @@
         }
     }
 
-    private static native long size0(Descriptor shm)
+    private static native long size0(int shm)
         throws IOException;
     /**
      * Retrieve the length of a shared memory segment in bytes.
@@ -236,7 +236,7 @@
         throws IOException, ClosedDescriptorException
     {
         if (shm.valid()) {
-            return size0(shm);
+            return size0(shm.fd());
         }
         else {
             throw new ClosedDescriptorException();

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/mutex.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/mutex.c?rev=887092&r1=887091&r2=887092&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/mutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/mutex.c Fri Dec  4 
08:01:49 2009
@@ -35,13 +35,11 @@
 }
 
 ACR_JNI_EXPORT_DECLARE(void, Mutex, lock0)(ACR_JNISTDARGS,
-                                           jobject mtxd)
+                                           jint md)
 {
     int rc = ACR_EBADF;
-    int md;
     UNREFERENCED_O;
 
-    md = ACR_DescriptorGetInt(_E, mtxd);
     if (md > 0) {
         rc = ACR_ProcMutexLock(_E, md);
     }
@@ -53,13 +51,11 @@
 }
 
 ACR_JNI_EXPORT_DECLARE(jboolean, Mutex, lock1)(ACR_JNISTDARGS,
-                                               jobject mtxd)
+                                               jint md)
 {
     int rc = ACR_EBADF;
-    int md;
     UNREFERENCED_O;
 
-    md = ACR_DescriptorGetInt(_E, mtxd);
     if (md > 0) {
         rc = ACR_ProcMutexTryLock(_E, md);
     }
@@ -74,13 +70,11 @@
 }
 
 ACR_JNI_EXPORT_DECLARE(void, Mutex, release0)(ACR_JNISTDARGS,
-                                              jobject mtxd)
+                                              jint md)
 {
     int rc = ACR_EBADF;
-    int md;
     UNREFERENCED_O;
 
-    md = ACR_DescriptorGetInt(_E, mtxd);
     if (md > 0) {
         rc = ACR_ProcMutexRelease(_E, md);
     }

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/sema.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/sema.c?rev=887092&r1=887091&r2=887092&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/sema.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/sema.c Fri Dec  4 
08:01:49 2009
@@ -53,13 +53,11 @@
 }
 
 ACR_JNI_EXPORT_DECLARE(void, Semaphore, wait0)(ACR_JNISTDARGS,
-                                               jobject semd)
+                                               jint sd)
 {
     int rc = ACR_EBADF;
-    int sd;
     UNREFERENCED_O;
 
-    sd = ACR_DescriptorGetInt(_E, semd);
     if (sd > 0) {
         rc = ACR_SemaphoreWait(_E, sd);
     }
@@ -71,13 +69,11 @@
 }
 
 ACR_JNI_EXPORT_DECLARE(jboolean, Semaphore, wait1)(ACR_JNISTDARGS,
-                                                  jobject semd)
+                                                  jint sd)
 {
     int rc = ACR_EBADF;
-    int sd;
     UNREFERENCED_O;
 
-    sd = ACR_DescriptorGetInt(_E, semd);
     if (sd > 0) {
         rc = ACR_SemaphoreTryWait(_E, sd);
     }
@@ -92,13 +88,11 @@
 }
 
 ACR_JNI_EXPORT_DECLARE(void, Semaphore, release0)(ACR_JNISTDARGS,
-                                                  jobject semd)
+                                                  jint sd)
 {
     int rc = ACR_EBADF;
-    int sd;
     UNREFERENCED_O;
 
-    sd = ACR_DescriptorGetInt(_E, semd);
     if (sd > 0) {
         rc = ACR_SemaphoreRelease(_E, sd);
     }
@@ -107,13 +101,11 @@
 }
 
 ACR_JNI_EXPORT_DECLARE(void, Semaphore, release1)(ACR_JNISTDARGS,
-                                                  jobject semd)
+                                                  jint sd)
 {
     int rc = ACR_EBADF;
-    int sd;
     UNREFERENCED_O;
 
-    sd = ACR_DescriptorGetInt(_E, semd);
     if (sd > 0) {
         rc = ACR_SemaphoreReset(_E, sd);
     }

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/shm.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/shm.c?rev=887092&r1=887091&r2=887092&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/shm.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/shm.c Fri Dec  4 
08:01:49 2009
@@ -117,14 +117,12 @@
 }
 
 ACR_JNI_EXPORT_DECLARE(jlong, SharedMemory, size0)(ACR_JNISTDARGS,
-                                                   jobject shmd)
+                                                   jint sd)
 {
     jlong rv = 0;
-    int sd;
 
     UNREFERENCED_O;
 
-    sd = ACR_DescriptorGetInt(_E, shmd);
     if (sd > 0) {
         rv = (jlong)ACR_ShmGetSize(sd);
     }


Reply via email to