Wiki Page Content

Differences between revisions 8 and 9
Revision 8 as of 2011-03-30 18:41:07
Size: 1980
Editor: SheenaSmith
Comment: update content - add enum section (3/25 82a09d5d0f07)
Revision 9 as of 2011-04-07 19:37:14
Size: 2133
Editor: SheenaSmith
Comment: add note about limitations (per Sam)
Deletions are marked like this. Additions are marked like this.
Line 17: Line 17:
We compile SDL into a DLL. This means that it's the DLL which creates a new thread for the calling process with the [[SDL_CreateThread]]() API. <<Color2(green,Should SDL_!CreateThread be un-hyperlinked here? No page yet. Doesn't look like it'll have one?)>> There is a problem with this, that only the RTL of the SDL.DLL will be initialized for those threads, and not the RTL of the calling application! We compile SDL into a DLL. This means that it's the DLL which creates a new thread for the calling process with the [[SDL_CreateThread]]() API. There is a problem with this, that only the RTL of the SDL.DLL will be initialized for those threads, and not the RTL of the calling application!
Line 27: Line 27:

''NOTE'': You should not expect to be able to create a window, render, or receive events on any thread other than the main one. For platform-specific exceptions or complicated options ask on the [[http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org|mailing list]].

DRAFT

Thread Management

Include File(s): SDL_thread.h, SDL_mutex.h (contains thread synchronization primitives)

Introduction

The SDL thread structure is defined in SDL_thread.c.

  • typedef struct SDL_Thread SDL_Thread;

We compile SDL into a DLL. This means that it's the DLL which creates a new thread for the calling process with the SDL_CreateThread() API. There is a problem with this, that only the RTL of the SDL.DLL will be initialized for those threads, and not the RTL of the calling application!

To solve this, we make a little hack here. green

We'll always use the caller's _beginthread() and _endthread() APIs to start a new thread. This way, if it's the SDL.DLL which uses this API, then the RTL of SDL.DLL will be used to create the new thread, and if it's the application, then the RTL of the application will be used.

So, in short: Always use the _beginthread() and _endthread() of the calling runtime library!

green

NOTE: You should not expect to be able to create a window, render, or receive events on any thread other than the main one. For platform-specific exceptions or complicated options ask on the mailing list.

Enumerations

Functions


CategoryCategory

None: CategoryThread (last edited 2017-07-15 21:51:08 by PhilippWiesemann)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit