+namespace simgrid {
+namespace msg {
+
+bool Comm::test()
+{
+ bool finished = false;
+
+ try {
+ finished = s_comm->test();
+ if (finished && task_received != nullptr) {
+ /* I am the receiver */
+ (*task_received)->set_not_used();
+ }
+ } catch (simgrid::TimeoutError& e) {
+ status_ = MSG_TIMEOUT;
+ finished = true;
+ } catch (simgrid::CancelException& e) {
+ status_ = MSG_TASK_CANCELED;
+ finished = true;
+ } catch (xbt_ex& e) {
+ if (e.category == network_error) {
+ status_ = MSG_TRANSFER_FAILURE;
+ finished = true;
+ } else {
+ throw;
+ }
+ }
+
+ return finished;
+}
+msg_error_t Comm::wait_for(double timeout)
+{
+ try {
+ s_comm->wait_for(timeout);
+
+ if (task_received != nullptr) {
+ /* I am the receiver */
+ (*task_received)->set_not_used();
+ }
+
+ /* FIXME: these functions are not traceable */
+ } catch (simgrid::TimeoutError& e) {
+ status_ = MSG_TIMEOUT;
+ } catch (simgrid::CancelException& e) {
+ status_ = MSG_TASK_CANCELED;
+ } catch (xbt_ex& e) {
+ if (e.category == network_error)
+ status_ = MSG_TRANSFER_FAILURE;
+ else
+ throw;
+ }
+
+ return status_;
+}
+} // namespace msg
+} // namespace simgrid
+