Re: [AD] Potential uthreads hang on cleanup?

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Peter Wang wrote:
The right way to do things is not to use pthread_cancel at all. Sorry, I was still new to threads when I wrote that code. Patch attached, but I didn't test it with Kdevelop or whatever.

Looks alright.. though I haven't tested it myself. Three things, though..

+static int thread_alive = FALSE;

That should probably be volatile, shouldn't it? Since it gets changed in a seperate thread you don't want the compiler making stupid assumptions.

+   ASSERT(thread_alive);

I don't think that ASSERT is necesarry since AFAICT the only time the thread is created is right after it's set to TRUE. Plus, even if it is false, the thread will just close out on its own anyway.

+   ASSERT(!!thread == !!thread_alive);

Wouldn't ASSERT(thread && thread_alive); be faster? Or does the compiler do some nice optimizations here?




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/