----- Original Message ----- From: "Stefan Huelswitt" s.huelswitt@gmx.de Newsgroups: local.linux.vdr To: vdr@linuxtv.org Sent: Friday, March 24, 2006 2:28 PM Subject: Re: [vdr] Eggtimer-0.9.1 thread won't end
On 24 Mar 2006 Peter Juszack vdr@unterbrecher.de wrote:
I know that it would be possible to leave the Action mehtod via return. But I want to implement some clean up at after the action loop so the method must finish in al cases.
In that case you could leave the action loop with break. No need for another flag normaly.
That's right, of course - but I have to leave the while from within a switch case block so I have to define an own loop variable.
I don't understand why it is not possible to set the cThread::running member to false from within the action loop or use any other cThread implemented mechnism to leave the action loop. Leaving this to the plugin developer is not the best idea beacause of duplicate running variables.
Well, I don't see the problem.
It's not a real problem. But I remember that I copied parts of my code from other plugins which have own class-wide running variables. I believe that starting and stopping the thread should be implemented in the base class cThread in a way that a plugin developer uses a scheme without own status vars.
If you want to stop a thread from outside i.e. from another thread you use Cancel(), as this envolves signaling the running thread that it should shut down.
I am not connected to my VDR now, but as far as I remember Cancel(int seconds) is a protected method and has to be wrapped for public access. Maybe there is a Cancel(void) method which I have not deiscovered yet. That's what I mean - I saw different ways of implementing thread handling in almost every plugin allthough developers derived from cThread.
If you're on the thread i.e. inside Action() there is no need for any kind of signaling, you must only drop out of the Action() function to shut down the thread.
Should I place cleanup stuff in a destructor?
Regards.
-- Stefan Huelswitt s.huelswitt@gmx.de | http://www.muempf.de/
vdr mailing list vdr@linuxtv.org http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr