Re: [AD] New gfx api

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Angelo Mottola wrote:

This requires some lines of code to initialize a program that properly gets input. Can't we have an internal global queue, on which all event sources are automatically attached when created?


I don't like the automatic attachment at all.

(1) This code looks like a typo, but is what you need to not attach to the global queue:

      t = al_create_timer();
      al_unregister_event_source(NULL, (AL_EVENT_SOURCE*)t);

(2) If we make it so you can wait on queue from another thread, any code that assumes what event sources can be registered in the "global" queue is wrong. For example:

       /* thread */
       al_wait_for_event(NULL, &event);
       if (event.any.source == src1) {
       } else { /* assume src2 */
       }

       /* main */
       src3 = al_create_timer();
       al_unregister_event_source(NULL, (AL_EVENT_SOURCE*)src3);

Then an user could just specify NULL as event queue and this global queue is used instead. What do you think?


For convenience's sake, I think it's okay. (I might have changed my mind since the last time we discussed this, but don't bite me :-)

Alternatively, we could introduce a global variable instead of NULL. Or #define a macro to hide NULL behind a more meaningful name.

Peter




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/