public void Dispose() { if (_queue != null) { _queue.Clear(); _queue = null; } }
public WriteBehindQueueResponse GetWriteBehindQueue(WriteBehindQueueRequest req) { WriteBehindQueueResponse rsp = null; if (_dsManager != null) { return(rsp); } WriteBehindAsyncProcessor.WriteBehindQueue queueChunk = new WriteBehindAsyncProcessor.WriteBehindQueue(_parent.Context); int indexOfNextTask = 0; long currentChunkSize = 0; string nextChunkId = null; if (req != null) { if (NCacheLog.IsInfoEnabled) { NCacheLog.Info("DSReplicationCorr.GetWriteBehindQueue", "received chunk request; nextchunkId :" + req.NextChunkId); } DSWriteBehindOperation operation = null; if (_queue == null) { WriteBehindAsyncProcessor.WriteBehindQueue queue = null; if (_dsManager._writeBehindAsyncProcess != null) { queue = _dsManager._writeBehindAsyncProcess.CloneQueue(); } if (queue != null) { _queue = new WriteBehindAsyncProcessor.WriteBehindQueue(_parent.Context); _queue.MergeQueue(queue); } else { return(null); } } if (req.NextChunkId != null) { for (int i = 0; i < _queue.Count; i++) { operation = _queue[i] as DSWriteBehindOperation; if (operation != null) { if (operation.TaskId == req.NextChunkId) { indexOfNextTask = i; break; } } } } for (int i = indexOfNextTask; i < _queue.Count; i++) { operation = _queue[i] as DSWriteBehindOperation; if (operation != null) { if (currentChunkSize >= CHUNK_SIZE) { nextChunkId = operation.TaskId; break; } currentChunkSize += operation.Size; queueChunk.Enqueue(operation.Key, true, operation); } } if (nextChunkId == null) { _queue.Clear(); _queue = null; } if (queueChunk.Count > 0) { rsp = new WriteBehindQueueResponse(queueChunk, nextChunkId, null); } } return(rsp); }