コード例 #1
0
ファイル: jmsg_comm.cpp プロジェクト: simgrid/simgrid
JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Comm_test(JNIEnv *env, jobject jcomm) {
  msg_comm_t comm;
  comm = (msg_comm_t) (uintptr_t) env->GetLongField(jcomm, jcomm_field_Comm_bind);

  jboolean finished = env->GetBooleanField(jcomm, jcomm_field_Comm_finished);
  if (finished == JNI_TRUE) {
    return JNI_TRUE;
  }

  if (not comm) {
    jxbt_throw_null(env, "comm is null");
    return JNI_FALSE;
  }

  if (MSG_comm_test(comm)) {
    msg_error_t status = MSG_comm_get_status(comm);
    if (status == MSG_OK) {
      jcomm_bind_task(env,jcomm);
      return JNI_TRUE;
    } else {
      //send the correct exception
      jmsg_throw_status(env,status);
    }
  }
  return JNI_FALSE;
}
コード例 #2
0
ファイル: jmsg_comm.cpp プロジェクト: RockyMeadow/simgrid
JNIEXPORT void JNICALL
Java_org_simgrid_msg_Comm_waitCompletion(JNIEnv *env, jobject jcomm, jdouble timeout) {
  msg_comm_t comm = (msg_comm_t) (uintptr_t) env->GetLongField(jcomm, jcomm_field_Comm_bind);
  if (!comm) {
    jxbt_throw_native(env,bprintf("comm is null"));
    return;
  }

  jboolean finished = env->GetBooleanField(jcomm, jcomm_field_Comm_finished);
  if (finished == JNI_TRUE) {
    return;
  }

  msg_error_t status;
  status = MSG_comm_wait(comm,(double)timeout);
  env->SetBooleanField(jcomm, jcomm_field_Comm_finished, JNI_TRUE);
  if (status == MSG_OK) {
    jcomm_bind_task(env,jcomm);
    return;
  }
  else {
    jmsg_throw_status(env,status);
  }

}