Here are the examples of the csharp api System.Threading.ReaderWriterLockSlim.EnterReadLock() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
773 Examples
19
View Source File : Barrel.cs
License : MIT License
Project Creator : jamesmontemagno
License : MIT License
Project Creator : jamesmontemagno
public bool IsExpired(string key)
{
if (string.IsNullOrWhiteSpace(key))
throw new ArgumentException("Key can not be null or empty.", nameof(key));
var expired = true;
indexLocker.EnterReadLock();
try
{
if (index.ContainsKey(key))
expired = index[key].Item2 < DateTime.UtcNow;
}
finally
{
indexLocker.ExitReadLock();
}
return expired;
}
19
View Source File : Barrel.cs
License : MIT License
Project Creator : jamesmontemagno
License : MIT License
Project Creator : jamesmontemagno
public bool Exists(string key)
{
if (string.IsNullOrWhiteSpace(key))
throw new ArgumentException("Key can not be null or empty.", nameof(key));
var exists = false;
indexLocker.EnterReadLock();
try
{
exists = index.ContainsKey(key);
}
finally
{
indexLocker.ExitReadLock();
}
return exists;
}
19
View Source File : Channel.cs
License : MIT License
Project Creator : jasonswearingen
License : MIT License
Project Creator : jasonswearingen
public void Publish(TMessage message)
{
var _markSubsToClean = false;
rwLock.EnterReadLock();
var subs = GetSubscribers();
try
{
foreach (var weak in subs)
{
if (weak.TryGetTarget(out var sub))
{
//foreach (var message in messages)
{
sub.Enqueue(message);
}
}
else
{
_markSubsToClean = true;
}
}
}
finally
{
rwLock.ExitReadLock();
}
if (_markSubsToClean == true)
{
CleanSubs();
}
}
19
View Source File : ResourceSync.cs
License : GNU General Public License v3.0
Project Creator : jealouscloud
License : GNU General Public License v3.0
Project Creator : jealouscloud
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void UnsafeEnterRead()
{
_lock.EnterReadLock();
}
19
View Source File : MemoryCache.cs
License : MIT License
Project Creator : jjxtra
License : MIT License
Project Creator : jjxtra
public async Task<CachedItem<T>> GetOrCreate<T>(string key, Func<Task<CachedItem<T>>> notFound) where T : clreplaced
{
CachedItem<T> newItem = default;
cacheTimerLock.EnterReadLock();
try
{
if (cache.TryGetValue(key, out KeyValuePair<DateTime, object> cacheValue))
{
return new CachedItem<T>((T)cacheValue.Value, cacheValue.Key);
}
}
finally
{
cacheTimerLock.ExitReadLock();
}
if (notFound == null)
{
return new CachedItem<T>();
}
// most likely the callback needs to make a network request, so don't do it in a lock
// it's ok if multiple calls stack on the same cache key, the last one to finish will win
newItem = await notFound();
// don't add null values to the cache
if (newItem.Value != null)
{
cacheTimerLock.EnterWriteLock();
try
{
cache[key] = new KeyValuePair<DateTime, object>(newItem.Expiration, newItem.Value);
}
finally
{
cacheTimerLock.ExitWriteLock();
}
}
return newItem;
}
19
View Source File : RuntimeSpecificsStore.cs
License : GNU Lesser General Public License v3.0
Project Creator : kagurazakasanae
License : GNU Lesser General Public License v3.0
Project Creator : kagurazakasanae
public static bool ShouldUseWeakRefs(IntPtr nativeClreplaced)
{
Lock.EnterReadLock();
try
{
return UsesWeakRefsStore.TryGetValue(nativeClreplaced, out var result) && result;
}
finally
{
Lock.ExitReadLock();
}
}
19
View Source File : RuntimeSpecificsStore.cs
License : GNU Lesser General Public License v3.0
Project Creator : kagurazakasanae
License : GNU Lesser General Public License v3.0
Project Creator : kagurazakasanae
public static bool IsInjected(IntPtr nativeClreplaced)
{
Lock.EnterReadLock();
try
{
return WasInjectedStore.TryGetValue(nativeClreplaced, out var result) && result;
}
finally
{
Lock.ExitReadLock();
}
}
19
View Source File : ThreadSafeList.cs
License : MIT License
Project Creator : kdcllc
License : MIT License
Project Creator : kdcllc
public int IndexOf(T item)
{
_lock.EnterReadLock();
int result;
try
{
result = _list.IndexOf(item);
}
finally
{
_lock.ExitReadLock();
}
return result;
}
19
View Source File : ThreadSafeList.cs
License : MIT License
Project Creator : kdcllc
License : MIT License
Project Creator : kdcllc
public bool Contains(T item)
{
_lock.EnterReadLock();
bool result;
try
{
result = _list.Contains(item);
}
finally
{
_lock.ExitReadLock();
}
return result;
}
19
View Source File : ThreadSafeList.cs
License : MIT License
Project Creator : kdcllc
License : MIT License
Project Creator : kdcllc
public IEnumerator<T> GetEnumerator()
{
_lock.EnterReadLock();
try
{
foreach (var value in _list)
{
yield return value;
}
}
finally
{
_lock.ExitReadLock();
}
}
19
View Source File : MultiKeyDictionary.cs
License : GNU General Public License v3.0
Project Creator : Keelhauled
License : GNU General Public License v3.0
Project Creator : Keelhauled
public L[] CloneSubKeys()
{
readerWriterLock.EnterReadLock();
try
{
var values = new L[subDictionary.Keys.Count];
subDictionary.Keys.CopyTo(values, 0);
return values;
}
finally
{
readerWriterLock.ExitReadLock();
}
}
19
View Source File : MultiKeyDictionary.cs
License : GNU General Public License v3.0
Project Creator : Keelhauled
License : GNU General Public License v3.0
Project Creator : Keelhauled
public bool TryGetValue(L subKey, out V val)
{
val = default;
readerWriterLock.EnterReadLock();
try
{
if(subDictionary.TryGetValue(subKey, out K primaryKey))
{
return baseDictionary.TryGetValue(primaryKey, out val);
}
}
finally
{
readerWriterLock.ExitReadLock();
}
return false;
}
19
View Source File : MultiKeyDictionary.cs
License : GNU General Public License v3.0
Project Creator : Keelhauled
License : GNU General Public License v3.0
Project Creator : Keelhauled
public bool TryGetValue(K primaryKey, out V val)
{
readerWriterLock.EnterReadLock();
try
{
return baseDictionary.TryGetValue(primaryKey, out val);
}
finally
{
readerWriterLock.ExitReadLock();
}
}
19
View Source File : MultiKeyDictionary.cs
License : GNU General Public License v3.0
Project Creator : Keelhauled
License : GNU General Public License v3.0
Project Creator : Keelhauled
public IEnumerator<KeyValuePair<K, V>> GetEnumerator()
{
readerWriterLock.EnterReadLock();
try
{
return baseDictionary.GetEnumerator();
}
finally
{
readerWriterLock.ExitReadLock();
}
}
19
View Source File : MultiKeyDictionary.cs
License : GNU General Public License v3.0
Project Creator : Keelhauled
License : GNU General Public License v3.0
Project Creator : Keelhauled
public V[] CloneValues()
{
readerWriterLock.EnterReadLock();
try
{
var values = new V[baseDictionary.Values.Count];
baseDictionary.Values.CopyTo(values, 0);
return values;
}
finally
{
readerWriterLock.ExitReadLock();
}
}
19
View Source File : MultiKeyDictionary.cs
License : GNU General Public License v3.0
Project Creator : Keelhauled
License : GNU General Public License v3.0
Project Creator : Keelhauled
public K[] ClonePrimaryKeys()
{
readerWriterLock.EnterReadLock();
try
{
var values = new K[baseDictionary.Keys.Count];
baseDictionary.Keys.CopyTo(values, 0);
return values;
}
finally
{
readerWriterLock.ExitReadLock();
}
}
19
View Source File : ConcurrentList.cs
License : GNU General Public License v3.0
Project Creator : KoalaBear84
License : GNU General Public License v3.0
Project Creator : KoalaBear84
public bool Contains(T item)
{
_lock.EnterReadLock();
try
{
return IndexOfInternal(item) != -1;
}
finally
{
_lock.ExitReadLock();
}
}
19
View Source File : ConcurrentList.cs
License : GNU General Public License v3.0
Project Creator : KoalaBear84
License : GNU General Public License v3.0
Project Creator : KoalaBear84
public IEnumerator<T> GetEnumerator()
{
_lock.EnterReadLock();
try
{
for (int i = 0; i < _count; i++)
{
// deadlocking potential mitigated by lock recursion enforcement
yield return _arr[i];
}
}
finally
{
_lock.ExitReadLock();
}
}
19
View Source File : ConcurrentList.cs
License : GNU General Public License v3.0
Project Creator : KoalaBear84
License : GNU General Public License v3.0
Project Creator : KoalaBear84
public int IndexOf(T item)
{
_lock.EnterReadLock();
try
{
return IndexOfInternal(item);
}
finally
{
_lock.ExitReadLock();
}
}
19
View Source File : ConcurrentList.cs
License : GNU General Public License v3.0
Project Creator : KoalaBear84
License : GNU General Public License v3.0
Project Creator : KoalaBear84
public void CopyTo(T[] array, int arrayIndex)
{
_lock.EnterReadLock();
try
{
if (_count > array.Length - arrayIndex)
{
throw new ArgumentException("Destination array was not long enough.");
}
Array.Copy(_arr, 0, array, arrayIndex, _count);
}
finally
{
_lock.ExitReadLock();
}
}
19
View Source File : MemoizingMRUCache.cs
License : MIT License
Project Creator : Kooboo
License : MIT License
Project Creator : Kooboo
public TVal Get(TParam key, object context = null)
{
Contract.Requires(key != null);
bool hasReadLock = false;
bool hasWriteLock = false;
try {
hasReadLock = true;
gate.EnterReadLock();
if (cacheEntries.ContainsKey(key)) {
var found = cacheEntries[key];
cacheMRUList.Remove(found.Item1);
cacheMRUList.AddFirst(found.Item1);
return found.Item2;
}
hasReadLock = false;
gate.ExitReadLock();
var result = calculationFunction(key, context);
hasWriteLock = true;
gate.EnterWriteLock();
var node = new LinkedListNode<TParam>(key);
cacheMRUList.AddFirst(node);
cacheEntries[key] = new Tuple<LinkedListNode<TParam>, TVal>(node, result);
maintainCache();
return result;
} finally {
if (hasWriteLock) {
gate.ExitWriteLock();
} else if (hasReadLock) {
gate.ExitReadLock();
}
}
}
19
View Source File : MemoizingMRUCache.cs
License : MIT License
Project Creator : Kooboo
License : MIT License
Project Creator : Kooboo
public bool TryGet(TParam key, out TVal result)
{
Contract.Requires(key != null);
try {
gate.EnterReadLock();
Tuple<LinkedListNode<TParam>, TVal> output;
var ret = cacheEntries.TryGetValue(key, out output);
if (ret && output != null) {
cacheMRUList.Remove(output.Item1);
cacheMRUList.AddFirst(output.Item1);
result = output.Item2;
} else {
result = default(TVal);
}
return ret;
} finally {
gate.ExitReadLock();
}
}
19
View Source File : MemoizingMRUCache.cs
License : MIT License
Project Creator : Kooboo
License : MIT License
Project Creator : Kooboo
public IEnumerable<TVal> CachedValues()
{
try {
gate.EnterReadLock();
return cacheEntries.Select(x => x.Value.Item2).ToArray();
} finally {
gate.ExitReadLock();
}
}
19
View Source File : UsingLock‘T.cs
License : MIT License
Project Creator : LeoYang-Chuese
License : MIT License
Project Creator : LeoYang-Chuese
public IDisposable Read()
{
if (Enabled == false || _lockSlim.IsReadLockHeld || _lockSlim.IsWriteLockHeld)
return Disposable.Empty;
_lockSlim.EnterReadLock();
return new Lock(_lockSlim, false);
}
19
View Source File : SimpleProjectContent.cs
License : GNU Lesser General Public License v2.1
Project Creator : lepoco
License : GNU Lesser General Public License v2.1
Project Creator : lepoco
public ITypeDefinition GetClreplaced(string nameSpace, string name, int typeParameterCount, StringComparer nameComparer)
{
readerWriterLock.EnterReadLock();
try {
return types.GetClreplaced(nameSpace, name, typeParameterCount, nameComparer);
} finally {
readerWriterLock.ExitReadLock();
}
}
19
View Source File : SimpleProjectContent.cs
License : GNU Lesser General Public License v2.1
Project Creator : lepoco
License : GNU Lesser General Public License v2.1
Project Creator : lepoco
public IEnumerable<ITypeDefinition> GetClreplacedes()
{
readerWriterLock.EnterReadLock();
try {
// make a copy with ToArray() for thread-safe access
return types.GetClreplacedes().ToArray();
} finally {
readerWriterLock.ExitReadLock();
}
}
19
View Source File : SimpleProjectContent.cs
License : GNU Lesser General Public License v2.1
Project Creator : lepoco
License : GNU Lesser General Public License v2.1
Project Creator : lepoco
public IEnumerable<ITypeDefinition> GetClreplacedes(string nameSpace, StringComparer nameComparer)
{
readerWriterLock.EnterReadLock();
try {
// make a copy with ToArray() for thread-safe access
return types.GetClreplacedes(nameSpace, nameComparer).ToArray();
} finally {
readerWriterLock.ExitReadLock();
}
}
19
View Source File : SimpleProjectContent.cs
License : GNU Lesser General Public License v2.1
Project Creator : lepoco
License : GNU Lesser General Public License v2.1
Project Creator : lepoco
public IEnumerable<string> GetNamespaces()
{
readerWriterLock.EnterReadLock();
try {
// make a copy with ToArray() for thread-safe access
return types.GetNamespaces().ToArray();
} finally {
readerWriterLock.ExitReadLock();
}
}
19
View Source File : SimpleProjectContent.cs
License : GNU Lesser General Public License v2.1
Project Creator : lepoco
License : GNU Lesser General Public License v2.1
Project Creator : lepoco
public string GetNamespace(string nameSpace, StringComparer nameComparer)
{
readerWriterLock.EnterReadLock();
try {
return types.GetNamespace(nameSpace, nameComparer);
} finally {
readerWriterLock.ExitReadLock();
}
}
19
View Source File : SimpleProjectContent.cs
License : GNU Lesser General Public License v2.1
Project Creator : lepoco
License : GNU Lesser General Public License v2.1
Project Creator : lepoco
public ISynchronizedTypeResolveContext Synchronize()
{
// don't acquire the lock on OutOfMemoryException etc.
ISynchronizedTypeResolveContext sync = new ReadWriteSynchronizedTypeResolveContext(types, readerWriterLock);
readerWriterLock.EnterReadLock();
return sync;
}
19
View Source File : SafeDictionary.cs
License : Apache License 2.0
Project Creator : littlenine12
License : Apache License 2.0
Project Creator : littlenine12
public bool TryGetValue(TKey key, out TValue value)
{
_padlock.EnterReadLock();
try
{
return _dictionary.TryGetValue(key, out value);
}
finally
{
_padlock.ExitReadLock();
}
}
19
View Source File : Keyboard.cs
License : BSD 2-Clause "Simplified" License
Project Creator : livingcomputermuseum
License : BSD 2-Clause "Simplified" License
Project Creator : livingcomputermuseum
public bool DataReady()
{
_lock.EnterReadLock();
bool ready = _keyboardQueue.Count > 0;
_lock.ExitReadLock();
return ready;
}
19
View Source File : TODClock.cs
License : BSD 2-Clause "Simplified" License
Project Creator : livingcomputermuseum
License : BSD 2-Clause "Simplified" License
Project Creator : livingcomputermuseum
public int ReadClockBit()
{
_lock.EnterReadLock();
// From BookKeepingTask.asm: "Bits from clock come in true, and most significant bit first."
int value = (_todValue & (0x80000000 >> (_todReadBit & 0x1f))) != 0 ? 0x40 : 0;
_lock.ExitReadLock();
return value;
}
19
View Source File : DWindow-IO.cs
License : BSD 2-Clause "Simplified" License
Project Creator : livingcomputermuseum
License : BSD 2-Clause "Simplified" License
Project Creator : livingcomputermuseum
private void RenderDisplay()
{
//
// Stuff the display data into the display texture
//
_textureLock.EnterReadLock();
IntPtr textureBits = IntPtr.Zero;
int pitch = 0;
SDL.SDL_LockTexture(_displayTexture, IntPtr.Zero, out textureBits, out pitch);
Marshal.Copy(_32bppDisplayBuffer, 0, textureBits, _32bppDisplayBuffer.Length);
SDL.SDL_UnlockTexture(_displayTexture);
//
// Render the display texture to the renderer
//
SDL.SDL_RenderCopy(_sdlRenderer, _displayTexture, IntPtr.Zero, IntPtr.Zero);
//
// And show it to us.
//
SDL.SDL_RenderPresent(_sdlRenderer);
_textureLock.ExitReadLock();
}
19
View Source File : AssetsCache.cs
License : MIT License
Project Creator : LykkeCity
License : MIT License
Project Creator : LykkeCity
public int GetreplacedetAccuracy(string replacedetId)
{
_lockSlim.EnterReadLock();
try
{
if (_replacedets.TryGetValue(replacedetId, out var result))
return result.Accuracy;
return DefaultreplacedetAccuracy;
}
finally
{
_lockSlim.ExitReadLock();
}
}
19
View Source File : AssetsCache.cs
License : MIT License
Project Creator : LykkeCity
License : MIT License
Project Creator : LykkeCity
public Ireplacedet GetreplacedetById(string replacedetId)
{
_lockSlim.EnterReadLock();
try
{
if (_replacedets.TryGetValue(replacedetId, out var result))
return result;
return null;
}
finally
{
_lockSlim.ExitReadLock();
}
}
19
View Source File : AccountAssetsCacheService.cs
License : MIT License
Project Creator : LykkeCity
License : MIT License
Project Creator : LykkeCity
public IAccountreplacedetPair GetAccountreplacedet(string tradingConditionId, string accountreplacedetId, string instrument)
{
IAccountreplacedetPair accountreplacedetPair = null;
_lockSlim.EnterReadLock();
try
{
var key = GetInstrumentCacheKey(tradingConditionId, accountreplacedetId, instrument);
if (_instrumentsCache.ContainsKey(key))
accountreplacedetPair = _instrumentsCache[key];
}
finally
{
_lockSlim.ExitReadLock();
}
if (accountreplacedetPair == null)
{
throw new Exception(string.Format(MtMessages.AccountreplacedetForTradingConditionNotFound,
tradingConditionId, accountreplacedetId, instrument));
}
if (accountreplacedetPair.LeverageMaintenance < 1)
{
throw new Exception(string.Format(MtMessages.LeverageMaintanceIncorrect, tradingConditionId,
accountreplacedetId, instrument));
}
if (accountreplacedetPair.LeverageInit < 1)
{
throw new Exception(string.Format(MtMessages.LeverageInitIncorrect, tradingConditionId, accountreplacedetId,
instrument));
}
return accountreplacedetPair;
}
19
View Source File : AccountAssetsCacheService.cs
License : MIT License
Project Creator : LykkeCity
License : MIT License
Project Creator : LykkeCity
public IAccountreplacedetPair GetAccountreplacedetThrowIfNotFound(string tradingConditionId,
string accountreplacedetId, string instrument)
{
IAccountreplacedetPair accountreplacedetPair = null;
_lockSlim.EnterReadLock();
try
{
var key = GetInstrumentCacheKey(tradingConditionId, accountreplacedetId, instrument);
if (_instrumentsCache.ContainsKey(key))
accountreplacedetPair = _instrumentsCache[key];
}
finally
{
_lockSlim.ExitReadLock();
}
if (accountreplacedetPair == null)
{
throw new Exception(string.Format(MtMessages.AccountreplacedetForTradingConditionNotFound,
tradingConditionId, accountreplacedetId, instrument));
}
return accountreplacedetPair;
}
19
View Source File : AccountAssetsCacheService.cs
License : MIT License
Project Creator : LykkeCity
License : MIT License
Project Creator : LykkeCity
public Dictionary<string, IAccountreplacedetPair[]> GetClientreplacedets(
IEnumerable<MarginTradingAccount> accounts)
{
var result = new Dictionary<string, IAccountreplacedetPair[]>();
if (accounts == null)
{
return result;
}
_lockSlim.EnterReadLock();
try
{
foreach (var account in accounts)
{
var key = GetAccountGroupCacheKey(account.TradingConditionId, account.BasereplacedetId);
if (!result.ContainsKey(account.BasereplacedetId) && _accountGroupCache.ContainsKey(key))
{
result.Add(account.BasereplacedetId, _accountGroupCache[key]);
}
}
}
finally
{
_lockSlim.ExitReadLock();
}
return result;
}
19
View Source File : AccountAssetsCacheService.cs
License : MIT License
Project Creator : LykkeCity
License : MIT License
Project Creator : LykkeCity
public ICollection<IAccountreplacedetPair> GetAccountreplacedets(string tradingConditionId, string basereplacedetId)
{
_lockSlim.EnterReadLock();
try
{
var key = GetAccountGroupCacheKey(tradingConditionId, basereplacedetId);
if (!_accountGroupCache.TryGetValue(key, out var replacedets))
{
return new List<IAccountreplacedetPair>();
}
return replacedets;
}
finally
{
_lockSlim.ExitReadLock();
}
}
19
View Source File : OrderCacheGroup.cs
License : MIT License
Project Creator : LykkeCity
License : MIT License
Project Creator : LykkeCity
public bool TryGetOrderById(string orderId, out Order result)
{
_lockSlim.EnterReadLock();
try
{
if (!_ordersById.ContainsKey(orderId))
{
result = null;
return false;
}
result = _ordersById[orderId];
return true;
}
finally
{
_lockSlim.ExitReadLock();
}
}
19
View Source File : OrderCacheGroup.cs
License : MIT License
Project Creator : LykkeCity
License : MIT License
Project Creator : LykkeCity
public IReadOnlyCollection<Order> GetOrdersByInstrument(string instrument)
{
if (string.IsNullOrWhiteSpace(instrument))
throw new ArgumentException(nameof(instrument));
_lockSlim.EnterReadLock();
try
{
if (!_orderIdsByInstrumentId.ContainsKey(instrument))
return new List<Order>();
return _orderIdsByInstrumentId[instrument].Select(id => _ordersById[id]).ToList();
}
finally
{
_lockSlim.ExitReadLock();
}
}
19
View Source File : OrderCacheGroup.cs
License : MIT License
Project Creator : LykkeCity
License : MIT License
Project Creator : LykkeCity
public ICollection<Order> GetOrdersByInstrumentAndAccount(string instrument, string accountId)
{
if (string.IsNullOrWhiteSpace(instrument))
throw new ArgumentException(nameof(instrument));
if (string.IsNullOrWhiteSpace(accountId))
throw new ArgumentException(nameof(instrument));
var key = GetAccountInstrumentCacheKey(accountId, instrument);
_lockSlim.EnterReadLock();
try
{
if (!_orderIdsByAccountIdAndInstrumentId.ContainsKey(key))
return new List<Order>();
return _orderIdsByAccountIdAndInstrumentId[key].Select(id => _ordersById[id]).ToList();
}
finally
{
_lockSlim.ExitReadLock();
}
}
19
View Source File : OrderCacheGroup.cs
License : MIT License
Project Creator : LykkeCity
License : MIT License
Project Creator : LykkeCity
public IReadOnlyCollection<Order> GetAllOrders()
{
_lockSlim.EnterReadLock();
try
{
return _ordersById.Values;
}
finally
{
_lockSlim.ExitReadLock();
}
}
19
View Source File : OrderCacheGroup.cs
License : MIT License
Project Creator : LykkeCity
License : MIT License
Project Creator : LykkeCity
public ICollection<Order> GetOrdersByAccountIds(params string[] accountIds)
{
_lockSlim.EnterReadLock();
var result = new List<Order>();
try
{
foreach (var accountId in accountIds)
{
if (!_orderIdsByAccountId.ContainsKey(accountId))
continue;
foreach (var orderId in _orderIdsByAccountId[accountId])
result.Add(_ordersById[orderId]);
}
return result;
}
finally
{
_lockSlim.ExitReadLock();
}
}
19
View Source File : ReaderWriterLockHelper.cs
License : MIT License
Project Creator : LykkeCity
License : MIT License
Project Creator : LykkeCity
public Disposable EnterReadLock()
{
_lock.EnterReadLock();
return new Disposable(_lock, l => l.ExitReadLock());
}
19
View Source File : AccountsCacheService.cs
License : MIT License
Project Creator : LykkeCity
License : MIT License
Project Creator : LykkeCity
private MarginTradingAccount[] GetClientAccounts(string clientId)
{
_lockSlim.EnterReadLock();
try
{
if (clientId != null)
{
if (_accounts.ContainsKey(clientId))
return _accounts[clientId];
return Array.Empty<MarginTradingAccount>();
}
else
{
return _accounts.SelectMany(a => a.Value).ToArray();
}
}
finally
{
_lockSlim.ExitReadLock();
}
}
19
View Source File : MatchingEngineRoutesCacheService.cs
License : MIT License
Project Creator : LykkeCity
License : MIT License
Project Creator : LykkeCity
public IMatchingEngineRoute GetRoute(string id)
{
_lockSlim.EnterReadLock();
try
{
return _routes[id];
}
finally
{
_lockSlim.ExitReadLock();
}
}
19
View Source File : MatchingEngineRoutesCacheService.cs
License : MIT License
Project Creator : LykkeCity
License : MIT License
Project Creator : LykkeCity
public IMatchingEngineRoute[] GetRoutes()
{
_lockSlim.EnterReadLock();
try
{
return _routes.Values.ToArray();
}
finally
{
_lockSlim.ExitReadLock();
}
}
19
View Source File : QuoteCacheService.cs
License : MIT License
Project Creator : LykkeCity
License : MIT License
Project Creator : LykkeCity
public InstrumentBidAskPair GetQuote(string instrument)
{
_lockSlim.EnterReadLock();
try
{
if (!_quotes.TryGetValue(instrument, out var quote))
throw new QuoteNotFoundException(instrument, string.Format(MtMessages.QuoteNotFound, instrument));
return quote;
}
finally
{
_lockSlim.ExitReadLock();
}
}
See More Examples