Skip to content

Instantly share code, notes, and snippets.

@ejrh
Created June 25, 2015 22:53
Show Gist options
  • Select an option

  • Save ejrh/7f68016b4f4a43504611 to your computer and use it in GitHub Desktop.

Select an option

Save ejrh/7f68016b4f4a43504611 to your computer and use it in GitHub Desktop.
Uint32 MESSAGE_EVENT = SDL_RegisterEvents(1);
/* In a thread dealing with network stuff */
while () {
shared_ptr<Message> message = read_message_from_network();
SDL_Event evt;
evt.type = MESSAGE_EVENT;
evt.user.data1 = // what?
SDL_PushEvent(&evt);
}
/* In the event-handling thread */
while () {
SDL_Event evt;
SDL_PollEvent(evt);
if (evt.type == MESSAGE_EVENT) {
shared_ptr<Message> message = // what?
handle_message(message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment