static int server(int argc, char *argv[])
{
   msg_task_t task =  MSG_task_create("a", 0, 0, (char*)"Some data");
   MSG_task_isend(task, "mailbox");

   xbt_assert(MSG_task_listen("mailbox")); // True (1)
   XBT_INFO("Task listen works on regular mailboxes");
   task = NULL;
   MSG_task_receive(&task, "mailbox");
   xbt_assert(!strcmp("Some data", MSG_task_get_data(task)), "Data received: %s", (char*)MSG_task_get_data(task));
   MSG_task_destroy(task);
   XBT_INFO("Data successfully received from regular mailbox");

   MSG_mailbox_set_async("mailbox2");
   task = MSG_task_create("b", 0, 0, (char*)"More data");
   MSG_task_isend(task, "mailbox2");

   xbt_assert(MSG_task_listen("mailbox2")); // used to break.
   XBT_INFO("Task listen works on asynchronous mailboxes");
   task = NULL;
   MSG_task_receive(&task, "mailbox2");
   xbt_assert(!strcmp("More data", MSG_task_get_data(task)));
   MSG_task_destroy(task);
   XBT_INFO("Data successfully received from asynchronous mailbox");

   return 0;
}
Exemple #2
0
JNIEXPORT void JNICALL 
Java_org_simgrid_msg_Host_setAsyncMailbox(JNIEnv * env, jclass cls_arg, jobject jname){

  const char *name = (*env)->GetStringUTFChars(env, jname, 0);
  MSG_mailbox_set_async(name);
  (*env)->ReleaseStringUTFChars(env, jname, name);

}