Esempio n. 1
0
        private void ReportCloseToParentReaders()
        {
            // LUCENENET specific - since ConditionalWeakTable doesn't synchronize
            // on the enumerator, we need to do external synchronization to make them threadsafe.
            UninterruptableMonitor.Enter(parentReadersLock);
            try
            {
#if FEATURE_CONDITIONALWEAKTABLE_ENUMERATOR
                foreach (var kvp in parentReaders)
                {
                    IndexReader target = kvp.Key;
#else
                var e = new Events.GetParentReadersEventArgs();
                eventAggregator.GetEvent <Events.GetParentReadersEvent>().Publish(e);
                foreach (var target in e.ParentReaders)
                {
#endif
                    // LUCENENET: This probably can't happen, but we are being defensive to avoid exceptions
                    if (target != null)
                    {
                        //Using weak references
                        target.closedByChild = true;
                        // cross memory barrier by a fake write:
                        target.refCount.AddAndGet(0);
                        // recurse:
                        target.ReportCloseToParentReaders();
                    }
                }
            }
            finally
            {
                UninterruptableMonitor.Exit(parentReadersLock);
            }
        }
Esempio n. 2
0
        private void ReportCloseToParentReaders()
        {
            // LUCENENET specific - since neither WeakDictionary nor ConditionalWeakTable synchronize
            // on the enumerator, we need to do external synchronization to make them threadsafe.
            UninterruptableMonitor.Enter(parentReadersLock);
            try
            {
                foreach (var kvp in parentReaders)
                {
                    IndexReader target = kvp.Key;

                    // LUCENENET: This probably can't happen, but we are being defensive to avoid exceptions
                    if (target != null)
                    {
                        //Using weak references
                        target.closedByChild = true;
                        // cross memory barrier by a fake write:
                        target.refCount.AddAndGet(0);
                        // recurse:
                        target.ReportCloseToParentReaders();
                    }
                }
            }
            finally
            {
                UninterruptableMonitor.Exit(parentReadersLock);
            }
        }
Esempio n. 3
0
        private void ReportCloseToParentReaders()
        {
            lock (parentReaders)
            {
                foreach (IdentityWeakReference <IndexReader> parent in parentReaders)
                {
                    //Using weak references
                    IndexReader target = parent.Target;

                    if (target != null)
                    {
                        target.ClosedByChild = true;
                        // cross memory barrier by a fake write:
                        target.refCount.AddAndGet(0);
                        // recurse:
                        target.ReportCloseToParentReaders();
                    }
                }
            }
        }
Esempio n. 4
0
        private void ReportCloseToParentReaders()
        {
            lock (parentReaders) // LUCENENET: This does not actually synchronize the set, it only ensures this method can only be entered by 1 thread
            {
                foreach (IdentityWeakReference <IndexReader> parent in parentReaders)
                {
                    //Using weak references
                    IndexReader target = parent.Target;

                    if (target != null)
                    {
                        target.closedByChild = true;
                        // cross memory barrier by a fake write:
                        target.refCount.AddAndGet(0);
                        // recurse:
                        target.ReportCloseToParentReaders();
                    }
                }
            }
        }