Assembla home | Assembla project page
 

Changeset 154

Show
Ignore:
Timestamp:
05/07/08 06:27:11 (5 months ago)
Author:
ToyinA
Message:

More updates for Thread safety where one controls the threads being created.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/QLNet/QLNet/Currencies/ExchangeRateManager.cs

    r153 r154  
    3434   { 
    3535      [ThreadStatic] 
    36       public static readonly ExchangeRateManager Instance = new ExchangeRateManager(); 
     36      private static ExchangeRateManager instance_ = null; 
     37      public static ExchangeRateManager Instance 
     38      { 
     39          get 
     40          { 
     41              if (instance_ == null) 
     42              { 
     43                  instance_ = 
     44                     new ExchangeRateManager(); 
     45              } 
     46              return instance_; 
     47          } 
     48      } 
     49 
    3750      private ExchangeRateManager() { 
    3851          addKnownRates(); 
  • trunk/QLNet/QLNet/Indexes/Indexmanager.cs

    r153 r154  
    2727 
    2828        [ThreadStatic] 
    29         private static Dictionary<string, TimeSeries<double>> data_ = new Dictionary<string, TimeSeries<double>>(); 
    30                  
     29        private static Dictionary<string, TimeSeries<double>> data_ = null; 
     30        public static Dictionary<string, TimeSeries<double>> Data 
     31        { 
     32            get 
     33            { 
     34                if (data_ == null) 
     35                { 
     36                    data_ = new Dictionary<string, TimeSeries<double>>(); 
     37                } 
     38                return data_; 
     39            } 
     40        } 
     41 
    3142                //! returns whether historical fixings were stored for the index 
    3243        public static bool hasHistory(string name) { 
    33                         return data_.ContainsKey(name); 
     44                        return Data.ContainsKey(name); 
    3445                } 
    3546                 
    3647        //! returns the (possibly empty) history of the index fixings 
    3748        public static TimeSeries<double> getHistory(string name) { 
    38             return hasHistory(name) ? data_[name] : new TimeSeries<double>(); 
     49            return hasHistory(name) ? Data[name] : new TimeSeries<double>(); 
    3950                } 
    4051                 
     
    4253        public static void setHistory(string name, TimeSeries<double> history) { 
    4354            if (hasHistory(name)) 
    44                 data_[name] = history; 
     55                Data[name] = history; 
    4556            else 
    46                 data_.Add(name, history); 
     57                Data.Add(name, history); 
    4758        } 
    4859 
    4960        //! observer notifying of changes in the index fixings 
    5061        public static TimeSeries<double> notifier(string name) { 
    51             return data_[name]; 
     62            return Data[name]; 
    5263        } 
    5364 
     
    5566        public static List<string> histories() { 
    5667            List<string> t = new List<string>(); 
    57             foreach (string s in data_.Keys) 
     68            foreach (string s in Data.Keys) 
    5869                t.Add(s); 
    5970                return t; 
     
    6273        //! clears the historical fixings of the index 
    6374        public static void clearHistory(string name) { 
    64                         data_[name].Clear(); 
     75                        Data[name].Clear(); 
    6576                } 
    6677 
    6778        //! clears all stored fixings 
    6879        public static void clearHistories() { 
    69                         data_.Clear(); 
     80                        Data.Clear(); 
    7081                } 
    7182        } 
  • trunk/QLNet/QLNet/Settings.cs

    r153 r154  
    2929 
    3030        [ThreadStatic] 
    31         private static Date evaluationDate_ = Date.Today
     31        private static Date evaluationDate_ = null
    3232 
    3333        [ThreadStatic] 
    3434        private static bool enforcesTodaysHistoricFixings_ = false; 
    3535 
    36         public static Date evaluationDate() { return evaluationDate_; } 
     36        public static Date evaluationDate()  
     37        { 
     38            if (evaluationDate_ == null) 
     39                evaluationDate_ = Date.Today; 
     40            return evaluationDate_;  
     41        } 
     42 
    3743        public static void setEvaluationDate(Date d) { 
    3844            evaluationDate_ = d;