/// <summary> /// Look up the Monitor for the specified object in the SyncBlock /// tables. If no Monitor exists for the object then one is created. /// </summary> private static Monitor GetMonitorFromSyncBlock(Object obj) { if (obj == null) { throw new ArgumentNullException(); } SyncBlock[] table; int index = SyncBlock.GetSyncBlockIndex(obj, out table); if (index < 0 || table[index].Monitor == null) { if (index < 0) { index = SyncBlock.LazyCreateSyncBlock(obj, out table); } Monitor monitor = table[index].Monitor; if (monitor == null) { Interlocked.CompareExchange(ref table[index].Monitor, new Monitor(), null); monitor = table[index].Monitor; } return(monitor); } else { return(table[index].Monitor); } }
bool TryGetSyncChannel(UInt32 channel, out SyncBlock syncBlock) { lock (_SyncMessageLock) { return(_SyncMessageDict.TryGetValue(channel, out syncBlock)); } }
public void TryToWakeUp(SyncBlock syncBlock) { if (!syncBlock.IsWorking) { syncBlock.IsWorking = true; syncBlock.Event.Set(); } }
public void StartLazyThread(SyncBlock syncBlock, int elementsCount) { if (elementsCount >= startPoint) { TryToWakeUp(syncBlock); LazyStartWasFired = true; } }
private void InitQueueManagers(QueueManager <BytesBlock>[] queuesManager) { var syncs = new SyncBlock[coresCount]; InitDefaultQueues(syncs); for (int i = 0; i < queuesManager.Length; i++) { queuesManager[i] = new QueueManager <BytesBlock>(_threadManager, syncs[i]); } }
UInt32 GetChannelForSync(out SyncBlock syncBlock) { lock (_SyncMessageLock) { UInt32 channel = IncCurChannel(); while (_SyncMessageDict.ContainsKey(channel)) { channel = IncCurChannel(); } syncBlock = new SyncBlock(); _SyncMessageDict.Add(channel, syncBlock); return(channel); } }
public bool GetLastSyncBlock(out ulong height, out byte[] hash) { lock (_sync) { SyncBlock syncBlock = _dataContext.SyncBlocks.OrderBy(b => b.SyncBlockId).FirstOrDefault(); if (syncBlock != null) { height = syncBlock.SyncBlockId; hash = syncBlock.Hash; return(true); } height = 0; hash = null; return(false); } }
void ClearChannelForSync() { lock (_SyncMessageLock) { foreach (SyncBlock syncBlock in _SyncMessageDict.Values) { try { syncBlock.Close(); } catch { } } _SyncMessageDict.Clear(); } SyncBlock.ClearAutoEvents(); }
public SerialTaskQueue(ILogger logger) { _logger = logger; _lockData = new SyncBlock(_logger); }
public QueueManager(ThreadManager threadManager, SyncBlock syncBlock) : base() { _threadManager = threadManager; _syncBlock = syncBlock; }