Skip to content

Commit ac4197f

Browse files
committed
Merge pull request #760 from nrgraham23/request_get_status_java
Java binding for MPI_REQUEST_GET_STATUS
2 parents 21dde0b + 9b5786d commit ac4197f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

ompi/mpi/java/c/mpi_Request.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,18 @@ JNIEXPORT jobject JNICALL Java_mpi_Request_testStatus(
171171
return flag ? ompi_java_status_new(env, &status) : NULL;
172172
}
173173

174+
JNIEXPORT jobject JNICALL Java_mpi_Request_getStatus(
175+
JNIEnv *env, jobject jthis, jlong handle)
176+
{
177+
MPI_Request req = (MPI_Request)handle;
178+
int flag;
179+
MPI_Status status;
180+
int rc = MPI_Request_get_status(req, &flag, &status);
181+
ompi_java_exceptionCheck(env, rc);
182+
(*env)->SetLongField(env, jthis, ompi_java.ReqHandle, (jlong)req);
183+
return flag ? ompi_java_status_new(env, &status) : NULL;
184+
}
185+
174186
JNIEXPORT jboolean JNICALL Java_mpi_Request_test(
175187
JNIEnv *env, jobject jthis, jlong handle)
176188
{

ompi/mpi/java/java/Request.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,23 @@ public final Status testStatus() throws MPIException
169169

170170
private native Status testStatus(long request) throws MPIException;
171171

172+
/**
173+
* Returns a status object if the operation identified by the request
174+
* is complete, or a null reference otherwise.
175+
* <p>Java binding of the MPI operation {@code MPI_REQUEST_GET_STATUS}.
176+
* <p>After the call, if the operation is complete (ie, if the return
177+
* value is non-null), the request object remains active.
178+
* @return status object
179+
* @throws MPIException Signals that an MPI exception of some sort has occurred.
180+
*/
181+
public final Status getStatus() throws MPIException
182+
{
183+
MPI.check();
184+
return getStatus(handle);
185+
}
186+
187+
private native Status getStatus(long request) throws MPIException;
188+
172189
/**
173190
* Returns true if the operation identified by the request
174191
* is complete, or false otherwise.

0 commit comments

Comments
 (0)