[vdr] [RFE] Soft-cancel cThread

Udo Richter udo_richter at gmx.de
Sun Sep 24 14:28:10 CEST 2006


Klaus Schmidinger wrote:
>> There are two ways this could be done. First, by adding a function 
>> SoftCancel() { running=false; }. Or second, by modifying Cancel() to 
>> just set running=false if called with Cancel(-1) or Cancel(0,false) or 
>> similar.
> 
> I would prefer using -1 as a special value for this, because this
> wouldn't require an interface change.

Agreed. I don't think that someone ever called Cancel(-1) before, so it 
should be ok to use that.

Btw: This one is shorter and functionally identical:

--- thread.c.old	2006-08-20 16:41:09.273625000 +0200
+++ thread.c	2006-09-24 14:22:59.064500000 +0200
@@ -293,7 +293,7 @@
  void cThread::Cancel(int WaitSeconds)
  {
    running = false;
-  if (active) {
+  if (active && WaitSeconds > -1) {
       if (WaitSeconds > 0) {
          for (time_t t0 = time(NULL) + WaitSeconds; time(NULL) < t0; ) {
              if (!Active())



Cheers,

Udo



More information about the vdr mailing list