/// <summary> /// Enqueue a item to be sent, if there are threads available, a new sending thread will be started /// </summary> /// <typeparam name="T"></typeparam> /// <param name="Item"></param> public void EnqueueSend <T>(T Item) where T : Hashable { if (!Initilized) { throw new InvalidOperationException("The peer has not been initialized"); } sendCache.AddOrUpdate(Item.ComputedHash, Item, ConnectTimeOut); SendQueue.Enqueue(Item.ComputedHash); if (MaxSendingThreads < sendingThreads) { Task.Run(() => ProcessSendQueue()); } }
/// <summary> /// Moves objects from one cache to another /// </summary> public void MigrateObjects(IObjectCache Source, IObjectCache Destination, ComparableBytesAbstract[] ObjectsToMove, bool RemoveSourceObject) { foreach (Hash key in ObjectsToMove) { var item = Source.Get(key); if (CacheIsPersistent) { item.LastPersistantSave = DateTime.Now; } Destination.AddOrUpdate(item); if (RemoveSourceObject) { Source.Remove(key); } } }