They may become useful to some lucky ones.
Java:
- * app_tokenring: new example, very similar to the MSG Token Ring
+ * New function: msg.Comm.waitAll()
+ * ex/app_tokenring: new example, very similar to the MSG Token Ring
-- $date Da SimGrid team <simgrid-devel@lists.gforge.inria.fr>
jmsg_throw_status(env,status);
}
}
+
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Comm_waitAll(JNIEnv *env, jclass cls, jobjectArray jcomms, jdouble timeout)
+{
+ int count = env->GetArrayLength(jcomms);
+ msg_comm_t* comms = xbt_new(msg_comm_t, count);
+
+ for (int i=0; i < count; i++) {
+ jobject jcomm = env->GetObjectArrayElement(jcomms, i);
+ if (env->ExceptionOccurred())
+ break;
+
+ comms[i] = (msg_comm_t) (uintptr_t) env->GetLongField(jcomm, jcomm_field_Comm_bind);
+ if (!comms[i]) {
+ jxbt_throw_native(env,bprintf("comm at rank %d is null",i));
+ return;
+ }
+
+ env->DeleteLocalRef(jcomm); // reduce the load on the garbage collector: we don't need that object anymore
+ }
+ MSG_comm_waitall(comms, count, static_cast<double>(timeout));
+ xbt_free(comms);
+}
+/*
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Comm_waitAny(JNIEnv *env, jobject jcomm, jarray comms)
+{
+
+}
+*/
JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Comm_test(JNIEnv *env, jobject jcomm);
JNIEXPORT void JNICALL Java_org_simgrid_msg_Comm_waitCompletion(JNIEnv *env, jobject jcomm, jdouble timeout);
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Comm_waitAll(JNIEnv *env, jclass cls, jobjectArray comms, jdouble timeout);
+//JNIEXPORT void JNICALL Java_org_simgrid_msg_Comm_waitAny(JNIEnv *env, jobject jcomm, jarray comms);
SG_END_DECL()
#endif /* MSG_JCOMM_H */
*/
public native void waitCompletion(double timeout) throws TransferFailureException, HostFailureException, TimeoutException;
+ /** Wait all of the communications */
+ public native static void waitAll(Comm[] comms, double timeout) throws TransferFailureException, HostFailureException, TimeoutException;
+ /** Wait all of the communications, with no maximal delay */
+ public static void waitAll(Comm[] comms) throws TransferFailureException, HostFailureException, TimeoutException {
+ waitAll(comms, -1.);
+ }
+ /** Wait any of the communications, and return the rank of the terminating comm */
+ //public native int waitAny(Comm[] comms);
/**
* Returns the task associated with the communication.
* if the communication isn't finished yet, will return null.