Well, actually I hesitated before answering Richard via Planet GNOME, and I considered mailing him. Finally urge combined with lazzyness (to figure out his e-mail address) won.
You should rather consider do yourself a clean cancel of the thread pthread_cancel() has a difficult semantic to implement and pthread_kill() will not be a clean solution. Resource allocated during the thread have to be cleaned up properly.
You'd rather do the following (with proper locks) :
thread_run() { while (has_some_work_to_do) { if (cancelled) return; do things; } } thread_cancel() { cancelled = true; }
(I did ask that question a number of years ago for Totem) (Matthias, I sent a mail to Richard months ago telling him his blog sucks for not allowing anonymous comments)
"g_thread_cancel?"
3 Comments -
Well, actually I hesitated before answering Richard via Planet GNOME, and I considered mailing him. Finally urge combined with lazzyness (to figure out his e-mail address) won.
21 November 2007 at 07:15
Hello,
You should rather consider do yourself a clean cancel of the thread pthread_cancel() has a difficult semantic to implement and pthread_kill() will not be a clean solution.
Resource allocated during the thread have to be cleaned up properly.
You'd rather do the following (with proper locks) :
thread_run()
{
while (has_some_work_to_do) {
if (cancelled)
return;
do things;
}
}
thread_cancel()
{
cancelled = true;
}
22 November 2007 at 01:21
Viêt Hoà, you already pasted that in Mathias' blog...
22 November 2007 at 09:20