Browse Source

Merge branch 'refs/heads/develop'

Exilon 5 years ago
parent
commit
5e90300369
2 changed files with 23 additions and 18 deletions
  1. 6 2
      Quick.AppService.pas
  2. 17 16
      Quick.Threads.pas

+ 6 - 2
Quick.AppService.pas

@@ -7,7 +7,7 @@
   Author      : Kike Pérez
   Author      : Kike Pérez
   Version     : 1.0
   Version     : 1.0
   Created     : 14/09/2017
   Created     : 14/09/2017
-  Modified    : 05/10/2017
+  Modified    : 01/12/2017
 
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
 
@@ -318,7 +318,7 @@ begin
     WriteLn(' [/instance:<service name>]'+#9+'Install service with a custom name');
     WriteLn(' [/instance:<service name>]'+#9+'Install service with a custom name');
   end
   end
   else Writeln(Format('%s [/console] [/install] [/remove] [/h] [/help]',[ExtractFileName(ParamStr(0))]));
   else Writeln(Format('%s [/console] [/install] [/remove] [/h] [/help]',[ExtractFileName(ParamStr(0))]));
-  WriteLn(' [/console]'+#9#9#9+'Run as a console application');
+  WriteLn(' [/console]'+#9#9#9+'Force run as a console application (when runned from another service)');
   WriteLn(' [/install]'+#9#9#9+'Install as a service');
   WriteLn(' [/install]'+#9#9#9+'Install as a service');
   WriteLn(' [/remove]'+#9#9#9+'Remove service');
   WriteLn(' [/remove]'+#9#9#9+'Remove service');
   WriteLn(' [/h /help]'+#9#9#9+'This help');
   WriteLn(' [/h /help]'+#9#9#9+'This help');
@@ -350,6 +350,10 @@ begin
         end;
         end;
         Self.Remove;
         Self.Remove;
       end
       end
+      else if ParamFindSwitch('console') then
+      begin
+        Writeln('Forced console mode');
+      end
       else Writeln('Unknow parameter specified!');
       else Writeln('Unknow parameter specified!');
   end
   end
   else
   else

+ 17 - 16
Quick.Threads.pas

@@ -7,7 +7,7 @@
   Author      : Kike Pérez
   Author      : Kike Pérez
   Version     : 1.5
   Version     : 1.5
   Created     : 09/03/2018
   Created     : 09/03/2018
-  Modified    : 14/09/2019
+  Modified    : 01/12/2019
 
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
 
@@ -273,7 +273,7 @@ type
     function WaitAndRetry(aWaitTimeArray : TArray<Integer>) : IWorkTask; overload;
     function WaitAndRetry(aWaitTimeArray : TArray<Integer>) : IWorkTask; overload;
     function WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor : Double) : IWorkTask; overload;
     function WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor : Double) : IWorkTask; overload;
     function WaitAndRetryForever(aWaitTimeBetweenRetriesMS : Integer) : IWorkTask; overload;
     function WaitAndRetryForever(aWaitTimeBetweenRetriesMS : Integer) : IWorkTask; overload;
-    function WaitAndRetryForever(aMaxRetries, aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor : Double) : IWorkTask; overload;
+    function WaitAndRetryForever(aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor : Double) : IWorkTask; overload;
     function SetParameter(const aName : string; aValue : TFlexValue; aOwned : Boolean) : IWorkTask; overload;
     function SetParameter(const aName : string; aValue : TFlexValue; aOwned : Boolean) : IWorkTask; overload;
     function SetParameter(const aName : string; aValue : TFlexValue) : IWorkTask; overload;
     function SetParameter(const aName : string; aValue : TFlexValue) : IWorkTask; overload;
     procedure Run;
     procedure Run;
@@ -295,7 +295,7 @@ type
     function WaitAndRetry(aWaitTimeArray : TArray<Integer>) : IScheduledTask; overload;
     function WaitAndRetry(aWaitTimeArray : TArray<Integer>) : IScheduledTask; overload;
     function WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor : Double) : IScheduledTask; overload;
     function WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor : Double) : IScheduledTask; overload;
     function WaitAndRetryForever(aWaitTimeBetweenRetriesMS : Integer) : IScheduledTask; overload;
     function WaitAndRetryForever(aWaitTimeBetweenRetriesMS : Integer) : IScheduledTask; overload;
-    function WaitAndRetryForever(aMaxRetries, aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor : Double) : IScheduledTask; overload;
+    function WaitAndRetryForever(aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor : Double) : IScheduledTask; overload;
     function CheckSchedule : Boolean;
     function CheckSchedule : Boolean;
     procedure DoExpire;
     procedure DoExpire;
     function GetTaskName : string;
     function GetTaskName : string;
@@ -393,7 +393,7 @@ type
     function WaitAndRetry(aWaitTimeArray : TArray<Integer>) : IWorkTask; overload;
     function WaitAndRetry(aWaitTimeArray : TArray<Integer>) : IWorkTask; overload;
     function WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor : Double) : IWorkTask; overload;
     function WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor : Double) : IWorkTask; overload;
     function WaitAndRetryForever(aWaitTimeBetweenRetriesMS : Integer) : IWorkTask; overload;
     function WaitAndRetryForever(aWaitTimeBetweenRetriesMS : Integer) : IWorkTask; overload;
-    function WaitAndRetryForever(aMaxRetries, aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor : Double) : IWorkTask; overload;
+    function WaitAndRetryForever(aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor : Double) : IWorkTask; overload;
     function SetParameter(const aName : string; aValue : TFlexValue; aOwned : Boolean) : IWorkTask; overload;
     function SetParameter(const aName : string; aValue : TFlexValue; aOwned : Boolean) : IWorkTask; overload;
     function SetParameter(const aName : string; aValue : TFlexValue) : IWorkTask; overload;
     function SetParameter(const aName : string; aValue : TFlexValue) : IWorkTask; overload;
     procedure Run; virtual;
     procedure Run; virtual;
@@ -452,7 +452,7 @@ type
     function WaitAndRetry(aWaitTimeArray : TArray<Integer>) : IScheduledTask; overload;
     function WaitAndRetry(aWaitTimeArray : TArray<Integer>) : IScheduledTask; overload;
     function WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor : Double) : IScheduledTask; overload;
     function WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor : Double) : IScheduledTask; overload;
     function WaitAndRetryForever(aWaitTimeBetweenRetriesMS : Integer) : IScheduledTask; overload;
     function WaitAndRetryForever(aWaitTimeBetweenRetriesMS : Integer) : IScheduledTask; overload;
-    function WaitAndRetryForever(aMaxRetries, aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor : Double) : IScheduledTask; overload;
+    function WaitAndRetryForever(aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor : Double) : IScheduledTask; overload;
     function SetParameter(const aName : string; aValue : TFlexValue; aOwned : Boolean) : IScheduledTask; overload;
     function SetParameter(const aName : string; aValue : TFlexValue; aOwned : Boolean) : IScheduledTask; overload;
     function SetParameter(const aName : string; aValue : TFlexValue) : IScheduledTask; overload;
     function SetParameter(const aName : string; aValue : TFlexValue) : IScheduledTask; overload;
     function IsFinished : Boolean;
     function IsFinished : Boolean;
@@ -1313,6 +1313,7 @@ end;
 
 
 procedure TTask.SetRetryPolicy(aMaxRetries, aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor: Double);
 procedure TTask.SetRetryPolicy(aMaxRetries, aWaitTimeBetweenRetriesMS : Integer; aWaitTimeMultiplierFactor: Double);
 begin
 begin
+  if aWaitTimeMultiplierFactor = 0 then raise ETaskParamError.Create('WaitTimeMultiplierFactor cannot be 0');
   fFaultControl.MaxRetries := aMaxRetries;
   fFaultControl.MaxRetries := aMaxRetries;
   fFaultControl.WaitTimeBetweenRetriesMS := aWaitTimeBetweenRetriesMS;
   fFaultControl.WaitTimeBetweenRetriesMS := aWaitTimeBetweenRetriesMS;
   fFaultControl.WaitTimeMultiplierFactor := aWaitTimeMultiplierFactor;
   fFaultControl.WaitTimeMultiplierFactor := aWaitTimeMultiplierFactor;
@@ -1328,7 +1329,7 @@ procedure TTask.SetRetryPolicy(aWaitTimeMSArray: TArray<Integer>);
 begin
 begin
   fFaultControl.MaxRetries := High(aWaitTimeMSArray) + 1;
   fFaultControl.MaxRetries := High(aWaitTimeMSArray) + 1;
   fFaultControl.WaitTimeBetweenRetriesMS := 0;
   fFaultControl.WaitTimeBetweenRetriesMS := 0;
-  fFaultControl.WaitTimeMultiplierFactor := 0;
+  fFaultControl.WaitTimeMultiplierFactor := 1;
   fFaultControl.WaitTimeMSArray := aWaitTimeMSArray;
   fFaultControl.WaitTimeMSArray := aWaitTimeMSArray;
   fCustomFaultPolicy := True;
   fCustomFaultPolicy := True;
 end;
 end;
@@ -1384,19 +1385,19 @@ end;
 function TWorkTask.Retry(aMaxRetries: Integer): IWorkTask;
 function TWorkTask.Retry(aMaxRetries: Integer): IWorkTask;
 begin
 begin
   Result := Self;
   Result := Self;
-  SetRetryPolicy(aMaxRetries,0,0);
+  SetRetryPolicy(aMaxRetries,0,1);
 end;
 end;
 
 
 function TWorkTask.RetryForever: IWorkTask;
 function TWorkTask.RetryForever: IWorkTask;
 begin
 begin
   Result := Self;
   Result := Self;
-  SetRetryPolicy(-1,0,0);
+  SetRetryPolicy(-1,0,1);
 end;
 end;
 
 
 function TWorkTask.WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS: Integer): IWorkTask;
 function TWorkTask.WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS: Integer): IWorkTask;
 begin
 begin
   Result := Self;
   Result := Self;
-  SetRetryPolicy(aMaxRetries,aWaitTimeBetweenRetriesMS,0);
+  SetRetryPolicy(aMaxRetries,aWaitTimeBetweenRetriesMS,1);
 end;
 end;
 
 
 function TWorkTask.WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS: Integer; aWaitTimeMultiplierFactor : Double): IWorkTask;
 function TWorkTask.WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS: Integer; aWaitTimeMultiplierFactor : Double): IWorkTask;
@@ -1414,10 +1415,10 @@ end;
 function TWorkTask.WaitAndRetryForever(aWaitTimeBetweenRetriesMS: Integer): IWorkTask;
 function TWorkTask.WaitAndRetryForever(aWaitTimeBetweenRetriesMS: Integer): IWorkTask;
 begin
 begin
   Result := Self;
   Result := Self;
-  SetRetryPolicy(-1,aWaitTimeBetweenRetriesMS,0);
+  SetRetryPolicy(-1,aWaitTimeBetweenRetriesMS,1);
 end;
 end;
 
 
-function TWorkTask.WaitAndRetryForever(aMaxRetries, aWaitTimeBetweenRetriesMS: Integer; aWaitTimeMultiplierFactor: Double): IWorkTask;
+function TWorkTask.WaitAndRetryForever(aWaitTimeBetweenRetriesMS: Integer; aWaitTimeMultiplierFactor: Double): IWorkTask;
 begin
 begin
   Result := Self;
   Result := Self;
   SetRetryPolicy(-1,aWaitTimeBetweenRetriesMS,aWaitTimeMultiplierFactor);
   SetRetryPolicy(-1,aWaitTimeBetweenRetriesMS,aWaitTimeMultiplierFactor);
@@ -1826,19 +1827,19 @@ end;
 function TScheduledTask.Retry(aMaxRetries: Integer): IScheduledTask;
 function TScheduledTask.Retry(aMaxRetries: Integer): IScheduledTask;
 begin
 begin
   Result := Self;
   Result := Self;
-  SetRetryPolicy(aMaxRetries,0,0);
+  SetRetryPolicy(aMaxRetries,0,1);
 end;
 end;
 
 
 function TScheduledTask.RetryForever: IScheduledTask;
 function TScheduledTask.RetryForever: IScheduledTask;
 begin
 begin
   Result := Self;
   Result := Self;
-  SetRetryPolicy(-1,0,0);
+  SetRetryPolicy(-1,0,1);
 end;
 end;
 
 
 function TScheduledTask.WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS: Integer): IScheduledTask;
 function TScheduledTask.WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS: Integer): IScheduledTask;
 begin
 begin
   Result := Self;
   Result := Self;
-  SetRetryPolicy(aMaxRetries,aWaitTimeBetweenRetriesMS,0);
+  SetRetryPolicy(aMaxRetries,aWaitTimeBetweenRetriesMS,1);
 end;
 end;
 
 
 function TScheduledTask.WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS: Integer; aWaitTimeMultiplierFactor : Double): IScheduledTask;
 function TScheduledTask.WaitAndRetry(aMaxRetries, aWaitTimeBetweenRetriesMS: Integer; aWaitTimeMultiplierFactor : Double): IScheduledTask;
@@ -1856,10 +1857,10 @@ end;
 function TScheduledTask.WaitAndRetryForever(aWaitTimeBetweenRetriesMS: Integer): IScheduledTask;
 function TScheduledTask.WaitAndRetryForever(aWaitTimeBetweenRetriesMS: Integer): IScheduledTask;
 begin
 begin
   Result := Self;
   Result := Self;
-  SetRetryPolicy(-1,aWaitTimeBetweenRetriesMS,0);
+  SetRetryPolicy(-1,aWaitTimeBetweenRetriesMS,1);
 end;
 end;
 
 
-function TScheduledTask.WaitAndRetryForever(aMaxRetries, aWaitTimeBetweenRetriesMS: Integer; aWaitTimeMultiplierFactor: Double): IScheduledTask;
+function TScheduledTask.WaitAndRetryForever(aWaitTimeBetweenRetriesMS: Integer; aWaitTimeMultiplierFactor: Double): IScheduledTask;
 begin
 begin
   Result := Self;
   Result := Self;
   SetRetryPolicy(-1,aWaitTimeBetweenRetriesMS,aWaitTimeMultiplierFactor);
   SetRetryPolicy(-1,aWaitTimeBetweenRetriesMS,aWaitTimeMultiplierFactor);