@@ -15,7 +15,6 @@ namespace LaunchDarkly.Client
1515 public class InMemoryFeatureStore : IFeatureStore
1616 {
1717 private static readonly ILog Log = LogManager . GetLogger ( typeof ( InMemoryFeatureStore ) ) ;
18- private static readonly int RwLockMaxWaitMillis = 1000 ;
1918 private readonly ReaderWriterLockSlim RwLock = new ReaderWriterLockSlim ( ) ;
2019 private readonly IDictionary < IVersionedDataKind , IDictionary < string , IVersionedData > > Items =
2120 new Dictionary < IVersionedDataKind , IDictionary < string , IVersionedData > > ( ) ;
@@ -31,9 +30,9 @@ public InMemoryFeatureStore() { }
3130 /// <inheritdoc/>
3231 public T Get < T > ( VersionedDataKind < T > kind , string key ) where T : class , IVersionedData
3332 {
33+ RwLock . EnterReadLock ( ) ;
3434 try
3535 {
36- RwLock . TryEnterReadLock ( RwLockMaxWaitMillis ) ;
3736 IDictionary < string , IVersionedData > itemsOfKind ;
3837 IVersionedData item ;
3938
@@ -64,9 +63,9 @@ public T Get<T>(VersionedDataKind<T> kind, string key) where T : class, IVersion
6463 /// <inheritdoc/>
6564 public IDictionary < string , T > All < T > ( VersionedDataKind < T > kind ) where T : class , IVersionedData
6665 {
66+ RwLock . EnterReadLock ( ) ;
6767 try
6868 {
69- RwLock . TryEnterReadLock ( RwLockMaxWaitMillis ) ;
7069 IDictionary < string , T > ret = new Dictionary < string , T > ( ) ;
7170 IDictionary < string , IVersionedData > itemsOfKind ;
7271 if ( Items . TryGetValue ( kind , out itemsOfKind ) )
@@ -90,9 +89,9 @@ public IDictionary<string, T> All<T>(VersionedDataKind<T> kind) where T : class,
9089 /// <inheritdoc/>
9190 public void Init ( IDictionary < IVersionedDataKind , IDictionary < string , IVersionedData > > items )
9291 {
92+ RwLock . EnterWriteLock ( ) ;
9393 try
9494 {
95- RwLock . TryEnterWriteLock ( RwLockMaxWaitMillis ) ;
9695 Items . Clear ( ) ;
9796 foreach ( var kindEntry in items )
9897 {
@@ -114,9 +113,9 @@ public void Init(IDictionary<IVersionedDataKind, IDictionary<string, IVersionedD
114113 /// <inheritdoc/>
115114 public void Delete < T > ( VersionedDataKind < T > kind , string key , int version ) where T : IVersionedData
116115 {
116+ RwLock . EnterWriteLock ( ) ;
117117 try
118118 {
119- RwLock . TryEnterWriteLock ( RwLockMaxWaitMillis ) ;
120119 IDictionary < string , IVersionedData > itemsOfKind ;
121120 if ( Items . TryGetValue ( kind , out itemsOfKind ) )
122121 {
@@ -136,9 +135,9 @@ public void Delete<T>(VersionedDataKind<T> kind, string key, int version) where
136135 /// <inheritdoc/>
137136 public void Upsert < T > ( VersionedDataKind < T > kind , T item ) where T : IVersionedData
138137 {
138+ RwLock . EnterWriteLock ( ) ;
139139 try
140140 {
141- RwLock . TryEnterWriteLock ( RwLockMaxWaitMillis ) ;
142141 IDictionary < string , IVersionedData > itemsOfKind ;
143142 if ( ! Items . TryGetValue ( kind , out itemsOfKind ) )
144143 {
0 commit comments