lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


2011/11/10 Philipp Janda <siffiejoe@gmx.net>:
>
> A proper solution would probably involve using pthread_cleanup_push to free
> the Lane's memory on actual cancellation.

I am not sure I get the usage of pthread_cancel_push right. What I
could do is this:
Add a pthread_cancel_push()/pthread_cancel_pop() pair at the beginning
and end of lane_main.
The callback I provide sets some flag in the s_lane structure.
In selfdestruct_atexit(), after the call to THREAD_KILL(), I
block-wait for this flag to be set in the structure, at which point I
can free it.
Would it be ok that way? When the thread actually terminates because
of the thread_kill() call, am I supposed to call pthread_cancel_pop()
(which I suppose might not be the case if execution doesn't reach the
end of lane_main)?


-- 
Benoit.