[RFE] Soft-cancel cThread
Commit Message
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:
Cheers,
Udo
Comments
Udo Richter wrote:
> 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())
Well, that's fine with me, too.
I guess you'll also want me to increase the API version number
if this goes into version 1.4.4?
Klaus
Klaus Schmidinger wrote:
> I guess you'll also want me to increase the API version number
> if this goes into version 1.4.4?
There's no urgent need from my point, nothing that will be publically
available any time soon (if at all), and nothing that should break
because of that. And the next APIVERSION bump is probably not that far
away anyway. ;)
Cheers,
Udo
@@ -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())