* @param timeout Time before giving up
*/
public native void waitCompletion(double timeout) throws TransferFailureException, HostFailureException, TimeoutException;
+
/**
* Returns the task associated with the communication.
* if the communication isn't finished yet, will return null.
this.coreAmount = coreAmount;
start(host,coreAmount);
}
+ protected void finalize() {
+ destroy();
+ }
+ /**
+ * Destroy the VM
+ */
+ protected native void destroy();
/**
* Natively implemented method starting the VM.
* @param coreAmount
jxbt_throw_native(env,bprintf("comm is null"));
return JNI_FALSE;
}
+ xbt_ex_t e;
TRY {
if (MSG_comm_test(comm)) {
MSG_error_t status = MSG_comm_get_status(comm);
return JNI_FALSE;
}
}
- CATCH_ANONYMOUS {
-
+ CATCH(e) {
+ xbt_ex_free(e);
}
+
return JNI_FALSE;
}
JNIEXPORT void JNICALL
}
MSG_error_t status;
+ xbt_ex_t e;
TRY {
status = MSG_comm_wait(comm,(double)timeout);
}
- CATCH_ANONYMOUS {
- return;
+ CATCH(e) {
+ xbt_ex_free(e);
}
(*env)->SetBooleanField(env, jcomm, jcomm_field_Comm_finished, JNI_TRUE);
if (status == MSG_OK) {
const char *storage = (*env)->GetStringUTFChars(env, jstorage, 0);
const char *path = (*env)->GetStringUTFChars(env, jpath, 0);
const char *mode = (*env)->GetStringUTFChars(env, jmode, 0);
-
- msg_file_t file = MSG_file_open(storage, path, mode);
-
+ msg_file_t file;
+ xbt_ex_t e;
+ TRY {
+ file = MSG_file_open(storage, path, mode);
+ }
+ CATCH(e) {
+ xbt_ex_free(e);
+ }
jfile_bind(env, jfile, file);
(*env)->ReleaseStringUTFChars(env, jstorage, storage);
JNIEXPORT jlong JNICALL
Java_org_simgrid_msg_File_read(JNIEnv *env, jobject jfile, jlong jsize, jlong jnmemb) {
msg_file_t file = jfile_get_native(env, jfile);
-
- size_t n = MSG_file_read(NULL,(size_t)jsize, (size_t)jnmemb, file);
-
+ size_t n;
+ xbt_ex_t e;
+ TRY {
+ n = MSG_file_read(NULL,(size_t)jsize, (size_t)jnmemb, file);
+ }
+ CATCH (e) {
+ xbt_ex_free(e);
+ }
return (jlong)n;
}
JNIEXPORT jlong JNICALL
Java_org_simgrid_msg_File_write(JNIEnv *env, jobject jfile, jlong jsize, jlong jnmemb) {
msg_file_t file = jfile_get_native(env, jfile);
-
- size_t n = MSG_file_write(NULL, (size_t)jsize, (size_t)jnmemb, file);
-
+ xbt_ex_t e;
+ size_t n;
+ TRY {
+ n = MSG_file_write(NULL, (size_t)jsize, (size_t)jnmemb, file);
+ }
+ CATCH(e) {
+ xbt_ex_free(e);
+ }
return (jlong)n;
}
JNIEXPORT void JNICALL
jxbt_throw_null(env,bprintf("No host can have a null name"));
return NULL;
}
- XBT_DEBUG("Looking for host '%s'",name);
/* get the host by name (the hosts are created during the grid resolution) */
host = MSG_get_host_by_name(name);
- XBT_DEBUG("MSG gave %p as native host", host);
if (!host) { /* invalid name */
jxbt_throw_host_not_found(env, name);
double time = jmillis / 1000 + jnanos / 1000;
MSG_error_t rv;
+ xbt_ex_t e;
TRY {
rv = MSG_process_sleep(time);
}
- CATCH_ANONYMOUS {
+ CATCH(e) {
+ xbt_ex_free(e);
return;
}
if (rv != MSG_OK) {
jdouble jseconds)
{
MSG_error_t rv;
+ xbt_ex_t e;
TRY {
rv = MSG_process_sleep((double)jseconds);
}
- CATCH_ANONYMOUS {
+ CATCH(e) {
+ xbt_ex_free(e);
return;
}
if (rv != MSG_OK) {
/* try to change the host of the process */
MSG_error_t rv = MSG_process_migrate(process, host);
- jxbt_check_res("MSG_process_migrate()", rv, MSG_OK,
- bprintf("unexpected error , please report this bug"));
+ if (rv != MSG_OK) {
+ jmsg_throw_status(env,rv);
+ }
/* change the host java side */
(*env)->SetObjectField(env, jprocess, jprocess_field_Process_host, jhost);
}
xbt_mutex_t mutex;
mutex = (xbt_mutex_t) (long) (*env)->GetLongField(env, obj, jsyncro_field_Mutex_bind);
- xbt_mutex_acquire(mutex);
+ xbt_ex_t e;
+ TRY {
+ xbt_mutex_acquire(mutex);
+ }
+ CATCH(e) {
+ xbt_ex_free(e);
+ }
}
JNIEXPORT void JNICALL
jxbt_throw_notbound(env, "task", jtask);
return;
}
+ xbt_ex_t e;
MSG_error_t rv;
TRY {
rv = MSG_task_execute(task);
}
- CATCH_ANONYMOUS {
+ CATCH(e) {
+ xbt_ex_free(e);
return;
}
if (rv != MSG_OK) {
/* Pass a global ref to the Jtask into the Ctask so that the receiver can use it */
MSG_task_set_data(task, (void *) (*env)->NewGlobalRef(env, jtask));
- rv = MSG_task_send_with_timeout(task, alias, (double) jtimeout);
-
+ xbt_ex_t e;
+ TRY {
+ rv = MSG_task_send_with_timeout(task, alias, (double) jtimeout);
+ }
+ CATCH(e) {
+ xbt_ex_free(e);
+ }
(*env)->ReleaseStringUTFChars(env, jalias, alias);
if (rv != MSG_OK) {
/* Pass a global ref to the Jtask into the Ctask so that the receiver can use it */
MSG_task_set_data(task, (void *) (*env)->NewGlobalRef(env, jtask));
- rv = MSG_task_send_bounded(task, alias, (double) jmaxRate);
+ xbt_ex_t e;
+ TRY {
+ rv = MSG_task_send_bounded(task, alias, (double) jmaxRate);
+ }
+ CATCH(e) {
+ xbt_ex_free(e);
+ }
(*env)->ReleaseStringUTFChars(env, jalias, alias);
- jxbt_check_res("MSG_task_send_bounded()", rv,
- MSG_HOST_FAILURE | MSG_TRANSFER_FAILURE | MSG_TIMEOUT,
- bprintf
- ("while sending task %s to mailbox %s with max rate %f",
- MSG_task_get_name(task), alias, (double) jmaxRate));
-
+ if (rv != MSG_OK) {
+ jmsg_throw_status(env, rv);
+ }
}
}
alias = (*env)->GetStringUTFChars(env, jalias, 0);
+ xbt_ex_t e;
TRY {
rv = MSG_task_receive_ext(task, alias, (double) jtimeout, host);
}
- CATCH_ANONYMOUS {
+ CATCH(e) {
+ xbt_ex_free(e);
return NULL;
}
if (rv != MSG_OK) {
xbt_free(task);
- jxbt_check_res("MSG_task_receive_ext()", rv,
- MSG_HOST_FAILURE | MSG_TRANSFER_FAILURE | MSG_TIMEOUT,
- bprintf("while receiving from mailbox %s", alias));
-
return (jobject) jtask_local;
}
const char *alias;
int rv;
+ xbt_ex_t e;
alias = (*env)->GetStringUTFChars(env, jalias, 0);
TRY {
rv = MSG_task_listen(alias);
}
- CATCH_ANONYMOUS {
+ CATCH(e) {
+ xbt_ex_free(e);
return 0;
}
(*env)->ReleaseStringUTFChars(env, jalias, alias);
return -1;
}
alias = (*env)->GetStringUTFChars(env, jalias, 0);
+ xbt_ex_t e;
+
TRY {
rv = MSG_task_listen_from_host(alias, host);
}
- CATCH_ANONYMOUS {
+ CATCH(e) {
+ xbt_ex_free(e);
return 0;
}
(*env)->ReleaseStringUTFChars(env, jalias, alias);
int rv;
const char *alias = (*env)->GetStringUTFChars(env, jalias, 0);
+ xbt_ex_t e;
TRY {
rv = MSG_task_listen_from(alias);
}
- CATCH_ANONYMOUS {
+ CATCH(e) {
+ xbt_ex_free(e);
return 0;
}
(*env)->ReleaseStringUTFChars(env, jalias, alias);
#include "jmsg_host.h"
#include "jmsg_process.h"
#include "jxbt_utilities.h"
-
+#include "msg/msg.h"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg);
void jvm_bind(JNIEnv *env, jobject jvm, msg_vm_t vm) {
jvm_bind(env,jvm,vm);
}
-
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_VM_destroy(JNIEnv *env, jobject jvm) {
+ /*msg_vm_t vm = jvm_get_native(env,jvm);
+ MSG_vm_destroy(vm);*/
+}
JNIEXPORT jboolean JNICALL
Java_org_simgrid_msg_VM_isSuspended(JNIEnv *env, jobject jvm) {
msg_vm_t vm = jvm_get_native(env,jvm);
JNIEXPORT void JNICALL
Java_org_simgrid_msg_VM_suspend(JNIEnv *env, jobject jvm) {
msg_vm_t vm = jvm_get_native(env,jvm);
-
- MSG_vm_suspend(vm);
+ xbt_ex_t e;
+ TRY {
+ MSG_vm_suspend(vm);
+ }
+ CATCH(e) {
+ xbt_ex_free(e);
+ }
}
JNIEXPORT void JNICALL
Java_org_simgrid_msg_VM_resume(JNIEnv *env, jobject jvm) {
msg_vm_t vm = jvm_get_native(env,jvm);
-
- MSG_vm_resume(vm);
+ xbt_ex_t e;
+ TRY {
+ MSG_vm_resume(vm);
+ }
+ CATCH(e) {
+ xbt_ex_free(e);
+ }
}
JNIEXPORT void JNICALL
Java_org_simgrid_msg_VM_shutdown(JNIEnv *env, jobject jvm) {
msg_vm_t vm = jvm_get_native(env,jvm);
-
- MSG_vm_shutdown(vm);
+ xbt_ex_t e;
+ TRY {
+ MSG_vm_shutdown(vm);
+ }
+ CATCH(e) {
+ xbt_ex_free(e);
+ }
}
JNIEXPORT void JNICALL
Java_org_simgrid_msg_VM_start(JNIEnv *env, jobject jvm, jobject jhost, jint jcoreamount);
/**
- * Class org_simgrid_msg_VM
- * Method all
- * Signature ()[Lorg/simgrid/msg/VM;
+ * Class org_simgrid_msg_VM
+ * Method destroy
+ * Signature ()V
*/
-JNIEXPORT jobjectArray JNICALL
-Java_org_simgrid_msg_VM_all(JNIEnv *env, jclass cls);
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_VM_destroy(JNIEnv *env, jobject jvm);
/**
* Class org_simgrid_msg_VM
* Method isSuspended