No subject


Wed Jan 24 21:54:03 PST 2007


/* Private data -- event queue */
#define MAXEVENTS 128
static struct {
 SDL_mutex *lock;
 int active;
 int head;
 int tail;
 SDL_Event event[MAXEVENTS];           ***********
 int wmmsg_next;
 struct SDL_SysWMmsg wmmsg[MAXEVENTS];
} SDL_EventQ;

The event queue stores the whole event itself, not pointers to events.  The
callback below is valid because SDL_PushEvent will copy the event into the
queue before it goes out of scope.  The documentation should be more
explicit about this.

Cheers,
Dan.


----- Original Message -----
From: "Will Benton" <willb at cs.wisc.edu>
To: <sdl at libsdl.org>
Sent: Saturday, November 09, 2002 6:00 PM
Subject: Re: [SDL] failure at SDL_AddEvent()


>
> On Saturday, November 9, 2002, at 05:06  PM, Daniel Goertzen wrote:
>
> > static Uint32 sdl_timer_callback(ep_session *session) {
> > SDL_Event event;
> > <fill in event with CONSTANT values>
> >  SDL_PushEvent(&event);
> >  return (55);
> >  }
>
> Unless I'm missing something, the address of "event" will be invalid
> (i.e. will not point to an SDL_Event) at the point of
> sdl_timer_callback's  return (since event is on the stack).  This would
> be a big problem unless SDL_PushEvent causes a context switch to the
> waiting thread (meaning that "event" is consumed before it is no longer
> on the stack).
>
> Even in that case, it would appear to be MP-unsafe.  Is this correct?
>
>
>
> best,
> wb
>
>
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
>





More information about the SDL mailing list