From: Michal MalĂ˝ Date: Fri, 19 Dec 2014 23:47:57 +0000 (+0100) Subject: Remove Auto_Lock locking mechanism as it is not longer needed X-Git-Url: https://gitweb.devoid-pointer.net/?a=commitdiff_plain;h=cd933d6453eb7125313bc19469ecff14c41be30d;p=Nine-Q.git Remove Auto_Lock locking mechanism as it is not longer needed --- diff --git a/src/problem_generators/problem_generator-acidobazic_suite.adb b/src/problem_generators/problem_generator-acidobazic_suite.adb index 12ef83a..7374365 100644 --- a/src/problem_generators/problem_generator-acidobazic_suite.adb +++ b/src/problem_generators/problem_generator-acidobazic_suite.adb @@ -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 diff --git a/src/problem_generators/problem_generator-solubility_suite.adb b/src/problem_generators/problem_generator-solubility_suite.adb index fad5287..db05b0f 100644 --- a/src/problem_generators/problem_generator-solubility_suite.adb +++ b/src/problem_generators/problem_generator-solubility_suite.adb @@ -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; diff --git a/src/problem_generators/problem_generator.adb b/src/problem_generators/problem_generator.adb index 140f737..93d3603 100644 --- a/src/problem_generators/problem_generator.adb +++ b/src/problem_generators/problem_generator.adb @@ -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 diff --git a/src/problem_generators/problem_generator.ads b/src/problem_generators/problem_generator.ads index 3ad5e7d..78a4655 100644 --- a/src/problem_generators/problem_generator.ads +++ b/src/problem_generators/problem_generator.ads @@ -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;