Doesn’t SDL_KillThread() work under windows? I’m pretty sure it does.
Just use that if all you need is to kill a thread with no clean up. This
is dangerous, of course, because you could kill a thread that has a
resource locked and then never be able to access the resource again.
Otherwise you pretty much have to use a flag. The warnings about using
SDL_KillThread() are mostly based on long experience with programming
threads. It is just not a good idea to kill threads with out knowing
where they are or what they are doing.
yeah, but it’s bad. i’m getting deadlocks because of it. i need to kill a
thread, but have a little more control – like ignore the signal till i’m
outside of critical sections (or similarly protect against problems).
Yeah, and that is exactly what a flag does. It tells the thread to quit,
when it is ready to quit.
The normal way for a thread to end is for the subroutine that you passed
to SDL_CreateThread() to return. That is, just let the top level
function of the thread return. The SDL wrapper code takes care of any OS
specific stuff, though most thread packages handle this for you. So, you
see, there is no need to have “SDL_ThreadDone()” function.
i’m looking for something akin to “exit()”. if you had to exit a program as
the last statement in your main() function, it would be a bit limiting,
don’t you think?
No, I don’t find it limiting at all. I find it very natural. Matter
of taste I suppose.
You could certainly use setjmp/longjump to leap back into the thread’s
top level function and then terminate. Not what you want, but it would
work.
it seems that not implementing a way to have a thread end
itself is similarly limiting.
Now we are walking into religious areas. I learned to program when the
religion of the day required you to not use goto, return, or exit.
Return and exit were supposed to be implied by reaching the bottom of a
function or program. The exit in the middle programming idiom is
considered to be a serious sin by followers of that religion. tOf
course, the proponents of that religion considered C to be blasphemous
and Pascal to be glorious. I was never a member of that religion but I
had to comply with it to graduate from college.
In my early working career I was forced to comply with the religions of
HIPO diagrams and Warnier-Orr charts which both discourage the exit in
the middle programming idiom. (I would rather write Warnier-Orr charts
than do eXtreme programming any day
The result is that I am perfectly happy programming without explicit
return or exit statements in a programming language and use them
sparingly and only withing certain coding idioms where they simplify the
code.
As a result of my early training I simply am not the least bit bothered
by the lack of a threadExit(). And, considering the kinds of design
horror it would allow I’m not sure I would use it if it existed.
Clearly you disagree, so there is nothing more for me to say on the
subject.
-miles vignol
Bob PendletonOn Tue, 2003-12-02 at 21:18, Miles Vignol wrote:
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
–
±--------------------------------------+