commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r806228 - /commons/sandbox/runtime/trunk/src/main/native/shared/sema.c
Date Thu, 20 Aug 2009 15:54:11 GMT
Author: mturk
Date: Thu Aug 20 15:54:10 2009
New Revision: 806228

URL: http://svn.apache.org/viewvc?rev=806228&view=rev
Log:
Few more semaphore wrapper API's

Modified:
    commons/sandbox/runtime/trunk/src/main/native/shared/sema.c

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=806228&r1=806227&r2=806228&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/sema.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/sema.c Thu Aug 20 15:54:10 2009
@@ -37,3 +37,76 @@
     return semo;
 }
 
+ACR_JNI_EXPORT_DECLARE(jint, Semaphore, close0)(ACR_JNISTDARGS,
+                                                jobject semd)
+{
+    int rc = ACR_EBADF;
+    int sd;
+    UNREFERENCED_O;
+
+    sd = ACR_DescriptorGetInt(_E, semd);
+    if (sd > 0) {    
+        ACR_DescriptorClear(_E, semd);
+        rc = ACR_SemaphoreClose(_E, sd);
+    }
+    return rc;
+}
+
+ACR_JNI_EXPORT_DECLARE(jboolean, Semaphore, wait0)(ACR_JNISTDARGS,
+                                                   jobject semd)
+{
+    int rc = ACR_EBADF;
+    int sd;
+    UNREFERENCED_O;
+
+    sd = ACR_DescriptorGetInt(_E, semd);
+    if (sd > 0) {    
+        rc = ACR_SemaphoreWait(_E, sd);
+    }
+    if (rc == ACR_SUCCESS)
+        return JNI_TRUE;
+    else {
+        if (rc != ACR_EBUSY) {
+            ACR_THROW_IO_IF_ERR(rc);
+        }
+        return JNI_FALSE;
+    }
+}
+
+ACR_JNI_EXPORT_DECLARE(jboolean, Semaphore, wait1)(ACR_JNISTDARGS,
+                                                   jobject semd)
+{
+    int rc = ACR_EBADF;
+    int sd;
+    UNREFERENCED_O;
+
+    sd = ACR_DescriptorGetInt(_E, semd);
+    if (sd > 0) {    
+        rc = ACR_SemaphoreTryWait(_E, sd);
+    }
+    if (rc == ACR_SUCCESS)
+        return JNI_TRUE;
+    else {
+        if (rc != ACR_EBUSY) {
+            ACR_THROW_IO_IF_ERR(rc);
+        }
+        return JNI_FALSE;
+    }
+}
+
+ACR_JNI_EXPORT_DECLARE(jboolean, Semaphore, release0)(ACR_JNISTDARGS,
+                                                      jobject semd)
+{
+    int rc = ACR_EBADF;
+    int sd;
+    UNREFERENCED_O;
+
+    sd = ACR_DescriptorGetInt(_E, semd);
+    if (sd > 0) {    
+        rc = ACR_SemaphoreRelease(_E, sd);
+    }
+
+    ACR_THROW_IO_IF_ERR(rc);
+    return rc ? JNI_FALSE : JNI_TRUE;
+}
+



Mime
View raw message