commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1094966 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/platform/windows/WindowsSemaphore.java native/os/win32/semaphore.c
Date Tue, 19 Apr 2011 09:31:32 GMT
Author: mturk
Date: Tue Apr 19 09:31:32 2011
New Revision: 1094966

URL: http://svn.apache.org/viewvc?rev=1094966&view=rev
Log:
Axe duplicate functionality native method

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsSemaphore.java
    commons/sandbox/runtime/trunk/src/main/native/os/win32/semaphore.c

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsSemaphore.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsSemaphore.java?rev=1094966&r1=1094965&r2=1094966&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsSemaphore.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsSemaphore.java
Tue Apr 19 09:31:32 2011
@@ -15,6 +15,7 @@
  */
 package org.apache.commons.runtime.platform.windows;
 
+import org.apache.commons.runtime.Errno;
 import org.apache.commons.runtime.Semaphore;
 import org.apache.commons.runtime.AlreadyExistsException;
 import org.apache.commons.runtime.NoSuchObjectException;
@@ -48,7 +49,6 @@ final class WindowsSemaphore extends Sem
         throws IllegalAccessException,
                NoSuchObjectException,
                SystemException;
-    private static native int  try0(long sema);
     private static native int  release0(long sema);
 
     public WindowsSemaphore(final String name, int value)
@@ -95,10 +95,10 @@ final class WindowsSemaphore extends Sem
     {
         if (handle == 0L)
             throw new ClosedDescriptorException();
-        int rc = try0(handle);
+        int rc = Win32.WaitForSingleObject(handle, 0);
         if (rc == 0)
             return true;
-        if (Status.IS_EBUSY(rc))
+        if (rc == Errno.EBUSY)
             return false;
         throw new SystemException(Status.describe(rc));
     }
@@ -121,7 +121,7 @@ final class WindowsSemaphore extends Sem
         if (handle == 0L)
             throw new ClosedDescriptorException();
         while (true) {
-            int rc = try0(handle);
+            int rc = Win32.WaitForSingleObject(handle, 0);
             if (rc == 0) {
                 once = true;
             }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/semaphore.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/semaphore.c?rev=1094966&r1=1094965&r2=1094966&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/semaphore.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/semaphore.c Tue Apr 19 09:31:32
2011
@@ -95,18 +95,6 @@ ACR_WIN_EXPORT(jlong, WindowsSemaphore, 
     return P2J(sp);
 }
 
-ACR_WIN_EXPORT(jint, WindowsSemaphore, try0)(JNI_STDARGS, jlong sem)
-{
-
-    DWORD ws = WaitForSingleObject(J2P(sem, HANDLE), 0);
-    if (ws == WAIT_OBJECT_0 || ws == WAIT_ABANDONED)
-        return 0;
-    else if (ws == WAIT_TIMEOUT)
-        return ACR_EBUSY;
-    else
-        return ACR_GET_OS_ERROR();
-}
-
 ACR_WIN_EXPORT(jint, WindowsSemaphore, release0)(JNI_STDARGS, jlong sem)
 {
     if (ReleaseSemaphore(J2P(sem, HANDLE), 1, 0))



Mime
View raw message