Browse Source

Merge branch 'develop'

Unknown 5 years ago
parent
commit
939c0c820f
2 changed files with 21 additions and 4 deletions
  1. 18 1
      Quick.Commons.pas
  2. 3 3
      Quick.Threads.pas

+ 18 - 1
Quick.Commons.pas

@@ -7,7 +7,7 @@
   Author      : Kike Pérez
   Version     : 1.8
   Created     : 14/07/2017
-  Modified    : 27/08/2019
+  Modified    : 15/09/2019
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
@@ -174,6 +174,8 @@ type
 
   //generates a random password with complexity options
   function RandomPassword(const PasswordLength : Integer; Complexity : TPasswordComplexity = [pfIncludeNumbers,pfIncludeSigns]) : string;
+  //generates a random string
+  function RandomString(const aLength: Integer) : string;
   //extracts file extension from a filename
   function ExtractFileNameWithoutExt(const FileName: string): string;
   //converts a Unix path to Windows path
@@ -429,6 +431,21 @@ begin
   end;
 end;
 
+function RandomString(const aLength: Integer) : string;
+const
+  chars : string = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
+var
+  i : Integer;
+  clong : Integer;
+begin
+  clong := High(chars);
+  SetLength(Result, aLength);
+  for i := 1 to aLength do
+  begin
+    Result[i] := chars[Random(clong) + 1];
+  end;
+end;
+
 function ExtractFileNameWithoutExt(const FileName: string): string;
 begin
   Result := TPath.GetFileNameWithoutExtension(FileName);

+ 3 - 3
Quick.Threads.pas

@@ -7,7 +7,7 @@
   Author      : Kike Pérez
   Version     : 1.5
   Created     : 09/03/2018
-  Modified    : 11/09/2019
+  Modified    : 14/09/2019
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
@@ -720,8 +720,8 @@ begin
   try
     if FQueueSize >= High(FQueue) then
     begin
-      if FQueueSize < 512 then Grow(FQueueSize * 2)
-        else Grow(10);
+      if FQueueSize < 1024 then Grow(FQueueSize)
+        else Grow(FQueueSize Div 2);
     end;
 
     Result := wrSignaled;