Author: mladen.turk(a)jboss.com
Date: 2007-10-04 02:21:54 -0400 (Thu, 04 Oct 2007)
New Revision: 1084
Modified:
trunk/sight/java/org/jboss/sight/NativeObject.java
trunk/sight/native/include/sight_local.h
trunk/sight/native/include/sight_types.h
trunk/sight/native/share/no.c
Log:
Add NativeObject interrupt method for breaking the long JNI calls
Modified: trunk/sight/java/org/jboss/sight/NativeObject.java
===================================================================
--- trunk/sight/java/org/jboss/sight/NativeObject.java 2007-10-04 05:43:07 UTC (rev 1083)
+++ trunk/sight/java/org/jboss/sight/NativeObject.java 2007-10-04 06:21:54 UTC (rev 1084)
@@ -47,6 +47,7 @@
private static native void clear0(long instance);
private static native void cbset0(long instance, Object cb)
throws OutOfMemoryError;
+ private static native void intr0(long instance);
/**
* Create new NativeObject without APR pool
@@ -74,6 +75,14 @@
}
/**
+ * Interrupt the pending native operation.
+ */
+ public void interrupt()
+ {
+ intr0(INSTANCE);
+ }
+
+ /**
* Destroy the object.
*/
public void destroy()
Modified: trunk/sight/native/include/sight_local.h
===================================================================
--- trunk/sight/native/include/sight_local.h 2007-10-04 05:43:07 UTC (rev 1083)
+++ trunk/sight/native/include/sight_local.h 2007-10-04 06:21:54 UTC (rev 1084)
@@ -387,7 +387,6 @@
#define SIGHT_LOCAL_END(N) apr_atomic_dec32(&(N)->refcount); }
apr_atomic_dec32(sight_global_atomic)
#define SIGHT_LOCAL_BRK(N) apr_atomic_dec32(&(N)->refcount);
apr_atomic_dec32(sight_global_atomic)
-#define SIGHT_LOCAL_IRQ(N) apr_atomic_read32(&(N)->interrupted)
#else
#define SIGHT_GLOBAL_TRY
@@ -396,10 +395,11 @@
#define SIGHT_LOCAL_TRY(N) if ((N))
#define SIGHT_LOCAL_END(N)
#define SIGHT_LOCAL_BRK(N)
-#define SIGHT_LOCAL_IRQ(N)
#endif /* SIGHT_APR_REFCOUNT */
+#define SIGHT_LOCAL_IRQ(N) apr_atomic_read32(&(N)->interrupted)
+
/* Statistics counters */
extern volatile apr_uint64_t sight_cnt_native_alloc;
extern volatile apr_uint64_t sight_cnt_native_create;
Modified: trunk/sight/native/include/sight_types.h
===================================================================
--- trunk/sight/native/include/sight_types.h 2007-10-04 05:43:07 UTC (rev 1083)
+++ trunk/sight/native/include/sight_types.h 2007-10-04 06:21:54 UTC (rev 1084)
@@ -115,8 +115,8 @@
struct sight_object_t {
#if SIGHT_APR_REFCOUNT
volatile apr_uint32_t refcount;
+#endif
volatile apr_uint32_t interrupted;
-#endif
apr_pool_t *pool;
void *native;
void *opaque;
Modified: trunk/sight/native/share/no.c
===================================================================
--- trunk/sight/native/share/no.c 2007-10-04 05:43:07 UTC (rev 1083)
+++ trunk/sight/native/share/no.c 2007-10-04 06:21:54 UTC (rev 1084)
@@ -281,3 +281,14 @@
}
} SIGHT_GLOBAL_END();
}
+
+SIGHT_EXPORT_DECLARE(void, NativeObject, intr0)(SIGHT_STDARGS,
+ jlong instance)
+{
+ sight_object_t *no = J2P(instance, sight_object_t *);
+
+ UNREFERENCED_STDARGS;
+ if (no) {
+ apr_atomic_inc32(&no->interrupted);
+ }
+}
Show replies by date