Beispiel #1
0
int module_stop (Q5Module* self)
{
  EcListCursor cursor;
  
  self->done = TRUE;
  
  eclist_cursor (self->threads, &cursor);
  
  while (eclist_cnext (&cursor))
  {
    ecthread_join (cursor.value);
  }
  
  while (eclist_cnext (&cursor))
  {
    ecthread_delete((EcThread*)(&cursor.value));
  }
  
  eclist_delete (&(self->threads));
  
  gse_destroy(&(self->entities));

  enet_host_destroy (self->server);

  enet_deinitialize();
   
  eclogger_fmt (LL_DEBUG, properties.name, "server", "stopped");  

  return TRUE;
}
Beispiel #2
0
int main (int argc, char *argv[])
{
  EcMessageData d01;
  EcMessagesOutput o1;
  EcThread threads [21];
  int i;

  ecmessages_initialize ();
  
  ecmessages_add (0x01, 0x01, m01, NULL);
  ecmessages_add (0x02, 0x01, m02, NULL);
  
  ecmessages_broadcast (0x01, NULL, NULL);
  
  ecmessages_send (0x02, 0x01, NULL, NULL);
  ecmessages_send (0x01, 0x01, NULL, NULL);
  ecmessages_send (0x01, 0x02, NULL, NULL);
    
  d01.type = 0;
  d01.ref = 0;
  d01.content = ecudc_create (EC_ALLOC, ENTC_UDC_STRING, NULL);
  ecudc_setS (d01.content, "Hello World");

  ecmessages_broadcast (0x01, &d01, NULL);
  
  ecudc_destroy(EC_ALLOC, &(d01.content));
  
  o1 = ecmessages_output_create (c01, NULL, 0, 0);
  ecmessages_broadcast (0x01, NULL, o1);
  ecmessages_output_destroy (&o1);
  
  printf("threading !!!!\n");
  
  for (i = 0; i < 20; i++)
  {
    threads [i] = ecthread_new ();
  }
  
  for (i = 0; i < 20; i++)
  {
    ecthread_start(threads [i], th01, NULL);
  }

  for (i = 0; i < 20; i++)
  {
    ecthread_join(threads [i]);
    ecthread_delete(&(threads [i]));
  }
  
  ecmessages_deinitialize ();
  
  return 0;
}