]> Devoid-pointer.net GitWeb - Nine-Q.git/commitdiff
Remove Auto_Lock locking mechanism as it is not longer needed
authorMichal Malý <madcatxster@devoid-pointer.net>
Fri, 19 Dec 2014 23:47:57 +0000 (00:47 +0100)
committerMichal Malý <madcatxster@devoid-pointer.net>
Fri, 19 Dec 2014 23:47:57 +0000 (00:47 +0100)
src/problem_generators/problem_generator-acidobazic_suite.adb
src/problem_generators/problem_generator-solubility_suite.adb
src/problem_generators/problem_generator.adb
src/problem_generators/problem_generator.ads

index 12ef83ac9387475c16d1024a39e85438b9016da1..737436552e472e9247ae9359792fe49d28e7955f 100644 (file)
@@ -26,13 +26,9 @@ package body Acidobazic_Suite is
     package FH is new Formatting_Helpers(pH_Float);
     use Answer_Info;
 
-    Guard: Auto_Lock.LC;
     pH: pH_Float;
     pH_Answered: pH_Float;
   begin
-    Auto_Lock.Init(Guard, Problem.Mutex'Unchecked_Access);
-    Guard.Lock;
-
     pH := Calculate_Solution(Problem);
     -- Verify answer data
     if Answer.Find(ANSWER_PH_KEY) = Answer_Info.No_Element then
@@ -88,14 +84,10 @@ package body Acidobazic_Suite is
   end Check_Answer;
 
   function Get_Assignment(Problem: in out Acidobazic_Problem; Assignment: in out Assignment_Info.Map; Resource_Prefix: in String) return RetCode is
-    Guard: Auto_Lock.LC;
     C: Assignment_Info.Cursor;
     Success: Boolean;
     pKx: pH_Float;
   begin
-    Auto_Lock.Init(Guard, Problem.Mutex'Unchecked_Access);
-    Guard.Lock;
-
     Assignment.Insert(PROBLEM_TYPE_KEY, PROBLEM_TYPE_ACIDOBAZIC, C, Success);
     if Success = False then
       return E_NOMEM;
@@ -146,13 +138,9 @@ package body Acidobazic_Suite is
   end Get_Assignment;
 
   function Get_Parameters(Problem: in out Acidobazic_Problem; Parameters: out Parameters_Info.Map) return RetCode is
-    Guard: Auto_Lock.LC;
     C: Parameters_Info.Cursor;
     Success: Boolean;
   begin
-    Auto_Lock.Init(Guard, Problem.Mutex'Unchecked_Access);
-    Guard.Lock;
-
     if Problem.Parameters.No_Both_Simplifications then
       Parameters.Insert(PARAMETER_NO_BOTH_SIMPLIFICATIONS_KEY, "True", C, Success);
       if Success = False then
@@ -166,15 +154,12 @@ package body Acidobazic_Suite is
     package Random_Substance_Type_Gen is new Ada.Numerics.Discrete_Random(Result_Subtype => Substance_Type);
     package Random_Dissoc_Type_Gen is new Ada.Numerics.Discrete_Random(Result_Subtype => Dissociation_Constant_Type);
 
-    Guard: Auto_Lock.LC;
     DCT_G: Random_Dissoc_Type_Gen.Generator;
     ST_G: Random_Substance_Type_Gen.Generator;
 
     cX_Min: pH_Float;
     cX_Max: pH_Float;
   begin
-    Auto_Lock.Init(Guard, Problem.Mutex'Unchecked_Access);
-    Guard.Lock;
     -- Dissociation constant type (pKa or pKb)
     Random_Dissoc_Type_Gen.Reset(Gen => DCT_G);
     Problem.DCT := Random_Dissoc_Type_Gen.Random(Gen => DCT_G);
@@ -214,12 +199,7 @@ package body Acidobazic_Suite is
 
   function Set_Parameters(Problem: in out Acidobazic_Problem; Parameters: in Parameters_Info.Map) return RetCode is
     use Parameters_Info;
-
-    Guard: Auto_Lock.LC;
   begin
-    Auto_Lock.Init(Guard, Problem.Mutex'Unchecked_Access);
-    Guard.Lock;
-
     if Parameters.Find(PARAMETER_NO_BOTH_SIMPLIFICATIONS_KEY) = Parameters_Info.No_Element then
       Problem.Parameters.No_Both_Simplifications := False;
     else
index fad528725fc27d2eff23f5a845449e93731fcbd4..db05b0fb747868f4b0939ec3af815e17d0a9ecc5 100644 (file)
@@ -23,7 +23,6 @@ package body Solubility_Suite is
     use Answer_Info;
     use FH;
 
-    Guard: Auto_Lock.LC;
     AF: SS_Float;
     Int_Part_Got: Integer;
     Int_Part_Calcd: Integer;
@@ -32,8 +31,6 @@ package body Solubility_Suite is
     Exp_Part_Got: Integer;
     Exp_Part_Calcd: Integer;
   begin
-    Auto_Lock.Init(Guard, Problem.Mutex'Unchecked_Access);
-    Guard.Lock;
     -- Check that there is a valid answer in the map
     if Answer.Find(ANSWER_NUM_KEY) = Answer_Info.No_Element then
       return No_Answer;
@@ -72,11 +69,7 @@ package body Solubility_Suite is
   function Get_Assignment(Problem: in out Solubility_Problem; Assignment: in out Assignment_Info.Map; Resource_Prefix: in String) return RetCode is
     package FH is new Formatting_Helpers(SS_Float);
     use FH;
-
-    Guard: Auto_Lock.LC;
   begin
-    Auto_Lock.Init(Guard, Problem.Mutex'Unchecked_Access);
-    Guard.Lock;
     Assignment.Insert(PROBLEM_TYPE_KEY, PROBLEM_TYPE_SOLUBILITY);
     Assignment.Insert(PROBLEM_SUBTYPE_KEY, Problem_Subtype'Image(Problem.Parameters.P_Subtype));
 
@@ -164,13 +157,9 @@ package body Solubility_Suite is
   end Get_Assignment;
   
   function Get_Parameters(Problem: in out Solubility_Problem; Parameters: out Parameters_Info.Map) return RetCode is
-    Guard: Auto_Lock.LC;
     C: Parameters_Info.Cursor;
     Success: Boolean;
   begin
-    Auto_Lock.Init(Guard, Problem.Mutex'Unchecked_Access);
-    Guard.Lock;
-
     if Problem.Parameters.Ionic_Strength then
       Parameters.Insert(PARAMETER_IONIC_STRENGTH_KEY, "True", C, Success);
       if Success = False then
@@ -194,14 +183,11 @@ package body Solubility_Suite is
     Stochio_RGen: Random_Stochio_Count.Generator;
     Float_RGen: Generator;
 
-    Guard: Auto_Lock.LC;
     M: Stochiometric_Count;          -- Number of cations
     N: Stochiometric_Count;          -- Number of anions
     Answer_Num: SS_Float;            -- Answer to this problem
     Prob_Data: Solubility_Problem_Data;  -- Assignment data
   begin
-    Auto_Lock.Init(Guard, Problem.Mutex'Unchecked_Access);
-    Guard.Lock;
     Reset(Gen => Float_RGen);
 
     -- Generate stochiometry of the molecul
@@ -300,11 +286,7 @@ package body Solubility_Suite is
 
   function Set_Parameters(Problem: in out Solubility_Problem; Parameters: in Parameters_Info.Map) return RetCode is
     use Parameters_Info;
-
-    Guard: Auto_Lock.LC;
   begin
-    Auto_Lock.Init(Guard, Problem.Mutex'Unchecked_Access);
-    Guard.Lock;
     -- Change ionic strength settings
     if Parameters.Find(PARAMETER_IONIC_STRENGTH_KEY) /= Parameters_Info.No_Element then
       Problem.Parameters.Ionic_Strength := True;
index 140f7377573fa206135581128f477ed41b711759..93d36034679def89b334c27be1817727a0dc5c7d 100644 (file)
@@ -1,30 +1,5 @@
 package body Problem_Generator is
 
-  package body Auto_Lock is
-    procedure Init(This: in out LC; Mutex: Simple_Mutex_All_Access; Auto_Unlock: in Boolean := True) is
-    begin
-      This.Auto_Unlock := Auto_Unlock;
-      This.Mutex := Mutex;
-    end;
-
-    procedure Lock(This: in out LC) is
-    begin
-      This.Mutex.Lock;
-    end Lock;
-
-    procedure Unlock(This: in out LC) is
-    begin
-      This.Mutex.Unlock;
-    end Unlock;
-
-    procedure Finalize(This: in out LC) is
-    begin
-      if This.Auto_Unlock then
-       This.Unlock;
-      end if;
-    end Finalize;
-  end Auto_Lock;
-
   function Get_Problem(P_Type: in Problem_Type) return access Chem_Problem'Class is
   begin
     case P_Type is
index 3ad5e7d2e46b24571769e61fe2c6ad73ffcb2b9e..78a4655e2e97c1f7933b82d25bc219b7f74e6e11 100644 (file)
@@ -20,24 +20,8 @@ package Problem_Generator is
   function Get_Problem(P_Type: in Problem_Type) return access Chem_Problem'Class;
 
 private
-  type Chem_Problem is abstract limited new Ada.Finalization.Limited_Controlled with
-    record
-      Mutex: aliased Simple_Mutex;
-    end record;
-
-  package Auto_Lock is
-    type LC is limited new Ada.Finalization.Limited_Controlled with private;
-      procedure Init(This: in out LC; Mutex: Simple_Mutex_All_Access; Auto_Unlock: in Boolean := True);
-      procedure Lock(This: in out LC);
-      procedure Unlock(This: in out LC);
-    private
-      type LC is limited new Ada.Finalization.Limited_Controlled with
-       record
-         Auto_Unlock: Boolean;
-         Mutex: Simple_Mutex_All_Access;
-       end record;
-      overriding procedure Finalize(This: in out LC);
-  end Auto_Lock;
+
+  type Chem_Problem is abstract limited new Ada.Finalization.Limited_Controlled with null record;
 
   package Acidobazic_Suite is
     use Problem_Generator_Syswides.Acidobazic_Suite;