[SDL] [Framework] Event-based Networking

Jared Maddox absinthdraco at gmail.com
Mon Mar 18 16:59:55 PDT 2013


> Date: Mon, 18 Mar 2013 05:30:07 -0700
> From: "Glocke" <cgloeckner at freenet.de>
> To: sdl at lists.libsdl.org
> Subject: Re: [SDL] [Framework] Event-based Networking
> Message-ID: <1363609807.m2f.36172 at forums.libsdl.org>
> Content-Type: text/plain; charset="iso-8859-1"
>
>
> Jared Maddox wrote:
>> Incidentally, where are you getting SDL_KillThread from? The only sign
>> of it that I see is for SDL 1.2
>
>
> I am using SDL 1.2 ^^
>

> Date: Mon, 18 Mar 2013 09:19:32 -0700
> From: Forest Hale <havoc at ghdigital.com>
> To: sdl at lists.libsdl.org
> Subject: Re: [SDL] [Framework] Event-based Networking
> Message-ID: <51473E94.5010409 at ghdigital.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On 03/18/2013 05:30 AM, Glocke wrote:
>> Jared Maddox wrote:
>>> Incidentally, where are you getting SDL_KillThread from? The only sign
>>> of it that I see is for SDL 1.2
>>
>> I am using SDL 1.2 ^^
>
> From experience porting apps from Windows to Linux and OSX, the platforms
> that have KillThread functionality have giant hazard warnings in the API
> docs, because it leaks resources (it does not
> terminate the thread cleanly and leaves it hanging around in the process
> table until the parent exits).
>
> So as a matter of design NEVER kill threads!  You need to tell them to exit
> by other means (and remember mutex is not the only synchronization primitive
> in your toolbox - semaphores and condvars have
> significant utility).
>
> --
> LordHavoc
>

In conclusion: Glocke, you should remove the kill function from your
code, and generify it sufficiently that it works natively with both
SDL 1.2 and SDL 2.0. Further, I suggest redesigning the thread api to
resemble the one provided by C++11, so that your code can be quickly
and easily used as a replacement for the C++11 library on platforms
that support SDL, but don't have C++11 thread support implemented.

I especially recommend the SDL 2.0 portion. SDL 1.2 is now antiquated
by virtue of it's API, and there's no changing that. If you want your
library to be used, then you need to target SDL 2.0



More information about the SDL mailing list