Author: clebert.suconic(a)jboss.com
Date: 2010-05-14 15:02:48 -0400 (Fri, 14 May 2010)
New Revision: 9233
Added:
trunk/native/cleanup-native
Modified:
trunk/native/src/JNI_AsynchronousFileImpl.cpp
trunk/native/src/Version.h
Log:
https://jira.jboss.org/jira/browse/HORNETQ-387 - using ByteBuffer for pointers
Added: trunk/native/cleanup-native
===================================================================
--- trunk/native/cleanup-native (rev 0)
+++ trunk/native/cleanup-native 2010-05-14 19:02:48 UTC (rev 9233)
@@ -0,0 +1,19 @@
+rm -r *log
+rm -r autom4te.cache
+rm -r aclocal.m4
+rm -r config.h
+rm -r config.in
+rm -r config.status
+rm -r configure
+rm -r libtool
+rm -r Makefile
+rm -r Makefile.in
+rm -r stamp-h1
+rm -r ./src/Makefile
+rm -r ./src/Makefile.in
+rm -r ./src/*.o
+rm -r ./src/.deps
+rm -r ./src/.libs
+rm -r ./src/org_hornetq_core_asyncio_impl_AsynchronousFileImpl.h
+rm -r ./src/disktest
+
Modified: trunk/native/src/JNI_AsynchronousFileImpl.cpp
===================================================================
--- trunk/native/src/JNI_AsynchronousFileImpl.cpp 2010-05-14 07:31:51 UTC (rev 9232)
+++ trunk/native/src/JNI_AsynchronousFileImpl.cpp 2010-05-14 19:02:48 UTC (rev 9233)
@@ -33,13 +33,19 @@
// This value is set here globally, to avoid passing stuff on stack between java and the
native layer on every sleep call
struct timespec nanoTime;
+inline AIOController * getController(JNIEnv *env, jobject & controllerAddress)
+{
+ return (AIOController *) env->GetDirectBufferAddress(controllerAddress);
+}
+
+
/*
* Class: org_jboss_jaio_libaioimpl_LibAIOController
* Method: init
* Signature: (Ljava/lang/String;Ljava/lang/Class;)J
*/
-JNIEXPORT jlong JNICALL Java_org_hornetq_core_asyncio_impl_AsynchronousFileImpl_init
+JNIEXPORT jobject JNICALL Java_org_hornetq_core_asyncio_impl_AsynchronousFileImpl_init
(JNIEnv * env, jclass clazz, jstring jstrFileName, jint maxIO, jobject logger)
{
AIOController * controller = 0;
@@ -65,7 +71,7 @@
// controller->log(env,4, "Controller initialized");
- return (jlong)controller;
+ return env->NewDirectByteBuffer(controller, 0);
}
catch (AIOException& e){
if (controller != 0)
@@ -78,11 +84,11 @@
}
JNIEXPORT void JNICALL Java_org_hornetq_core_asyncio_impl_AsynchronousFileImpl_read
- (JNIEnv *env, jobject objThis, jlong controllerAddress, jlong position, jlong size,
jobject jbuffer, jobject callback)
+ (JNIEnv *env, jobject objThis, jobject controllerAddress, jlong position, jlong size,
jobject jbuffer, jobject callback)
{
try
{
- AIOController * controller = (AIOController *) controllerAddress;
+ AIOController * controller = getController(env, controllerAddress);
void * buffer = env->GetDirectBufferAddress(jbuffer);
if (buffer == 0)
@@ -166,11 +172,11 @@
}
JNIEXPORT void JNICALL Java_org_hornetq_core_asyncio_impl_AsynchronousFileImpl_write
- (JNIEnv *env, jobject objThis, jlong controllerAddress, jlong sequence, jlong position,
jlong size, jobject jbuffer, jobject callback)
+ (JNIEnv *env, jobject objThis, jobject controllerAddress, jlong sequence, jlong
position, jlong size, jobject jbuffer, jobject callback)
{
try
{
- AIOController * controller = (AIOController *) controllerAddress;
+ AIOController * controller = getController(env, controllerAddress);
void * buffer = env->GetDirectBufferAddress(jbuffer);
if (buffer == 0)
@@ -193,11 +199,11 @@
JNIEXPORT void
Java_org_hornetq_core_asyncio_impl_AsynchronousFileImpl_internalPollEvents
- (JNIEnv *env, jclass, jlong controllerAddress)
+ (JNIEnv *env, jclass, jobject controllerAddress)
{
try
{
- AIOController * controller = (AIOController *) controllerAddress;
+ AIOController * controller = getController(env, controllerAddress);
controller->fileOutput.pollEvents(env);
}
catch (AIOException& e)
@@ -207,11 +213,11 @@
}
JNIEXPORT void JNICALL
Java_org_hornetq_core_asyncio_impl_AsynchronousFileImpl_stopPoller
- (JNIEnv *env, jclass, jlong controllerAddress)
+ (JNIEnv *env, jclass, jobject controllerAddress)
{
try
{
- AIOController * controller = (AIOController *) controllerAddress;
+ AIOController * controller = getController(env, controllerAddress);
controller->fileOutput.stopPoller(env);
}
catch (AIOException& e)
@@ -221,16 +227,13 @@
}
JNIEXPORT void JNICALL
Java_org_hornetq_core_asyncio_impl_AsynchronousFileImpl_closeInternal
- (JNIEnv *env, jclass, jlong controllerAddress)
+ (JNIEnv *env, jclass, jobject controllerAddress)
{
try
{
- if (controllerAddress != 0)
- {
- AIOController * controller = (AIOController *) controllerAddress;
- controller->destroy(env);
- delete controller;
- }
+ AIOController * controller = getController(env, controllerAddress);
+ controller->destroy(env);
+ delete controller;
}
catch (AIOException& e)
{
@@ -240,11 +243,11 @@
JNIEXPORT void JNICALL Java_org_hornetq_core_asyncio_impl_AsynchronousFileImpl_fill
- (JNIEnv * env, jclass, jlong controllerAddress, jlong position, jint blocks, jlong
size, jbyte fillChar)
+ (JNIEnv * env, jclass, jobject controllerAddress, jlong position, jint blocks, jlong
size, jbyte fillChar)
{
try
{
- AIOController * controller = (AIOController *) controllerAddress;
+ AIOController * controller = getController(env, controllerAddress);
controller->fileOutput.preAllocate(env, position, blocks, size, fillChar);
@@ -267,11 +270,11 @@
JNIEXPORT jlong JNICALL Java_org_hornetq_core_asyncio_impl_AsynchronousFileImpl_size0
- (JNIEnv * env, jobject, jlong controllerAddress)
+ (JNIEnv * env, jobject, jobject controllerAddress)
{
try
{
- AIOController * controller = (AIOController *) controllerAddress;
+ AIOController * controller = getController(env, controllerAddress);
long size = controller->fileOutput.getSize();
if (size < 0)
Modified: trunk/native/src/Version.h
===================================================================
--- trunk/native/src/Version.h 2010-05-14 07:31:51 UTC (rev 9232)
+++ trunk/native/src/Version.h 2010-05-14 19:02:48 UTC (rev 9233)
@@ -3,6 +3,6 @@
// This definition needs to match
org.hornetq.core.asyncio.impl.AsynchronousFileImpl.EXPECTED_NATIVE_VERSION
// Or else the native module won't be loaded because of version mismatches
-#define _VERSION_NATIVE_AIO 28
+#define _VERSION_NATIVE_AIO 29
#endif