예제 #1
0
파일: Peer.cs 프로젝트: JeremyOne/CryptLink
        /// <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());
            }
        }
예제 #2
0
        /// <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);
                }
            }
        }