コード例 #1
0
        private static Tuple <DupItem, TreeNodeDupMd5Full> AddDup(FileInfo fInfo, Action <DupItem> doLink)
        {
            var d = new DupItem(fInfo);
            var s = d.Size;
            var n = Root.Get(s);

            if (n == null)
            {
                lock (RootLock)
                    n = Root.GetOrNew(s);
            }

            Task.Run(() => doLink(d));

            var tFull = n.Add(d);

            return(Tuple.Create(d, tFull));
        }
コード例 #2
0
            public TreeNodeDupMd5Full Add(DupItem d)
            {
                if (Existing != null)
                {
                    KeyBeforeLock(d); // do this outside lock
                }
                IList <Tuple <TreeNodeBase, DupItem> > l;

                lock (Lock)
                {
                    if (Existing == null)
                    {
                        Existing = d;
                        return(null);
                    }
                    l = AddNonFirstLock(d); // do lock critical
                }

                return(AddNonFirstPostLock(l)); // do stuff not needing lock at this level
            }
コード例 #3
0
            protected override IList <Tuple <TreeNodeBase, DupItem> > AddNonFirstLock(DupItem d)
            {
                var unhandSibs = SubTree.Count == 0 ? new[] { Existing, d } : new[] { d };

                return(unhandSibs
                       .Select(s => Tuple.Create((TreeNodeBase)SubTree.GetOrNew(KeyBeforeLock(s)), s))
                       .ToList());
            }
コード例 #4
0
 protected override string KeyBeforeLock(DupItem x)
 {
     return(x.GetMd5OneBlock());
 }
コード例 #5
0
 protected abstract IList <Tuple <TreeNodeBase, DupItem> > AddNonFirstLock(DupItem d);
コード例 #6
0
 protected virtual string KeyBeforeLock(DupItem x)
 {
     return(null);
 }
コード例 #7
0
 protected override IList <Tuple <TreeNodeBase, DupItem> > AddNonFirstLock(DupItem d)
 {
     return(null);
 }