Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: private WeakRunnable wrapRunnable(@NonNull Runnable r)
        private WeakRunnable wrapRunnable(IRunnable r)
        {
            //noinspection ConstantConditions
            if (r == null)
            {
                throw new System.NullReferenceException("Runnable can't be null");
            }
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final ChainedRef hardRef = new ChainedRef(mLock, r);
            ChainedRef hardRef = new ChainedRef(mLock, r);

            mRunnables.insertAfter(hardRef);
            return(hardRef.wrapper);
        }
Пример #2
0
            public void Run()
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Runnable delegate = mDelegate.get();
                IRunnable @delegate = (IRunnable)mDelegate.Get();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final ChainedRef reference = mReference.get();
                ChainedRef reference = (ChainedRef)mReference.Get();

                if (reference != null)
                {
                    reference.remove();
                }
                if (@delegate != null)
                {
                    @delegate.Run();
                }
            }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: public void insertAfter(@NonNull ChainedRef candidate)
            public virtual void insertAfter(ChainedRef candidate)
            {
                @lock.Lock();
                try
                {
                    if (this.next != null)
                    {
                        this.next.prev = candidate;
                    }

                    candidate.next = this.next;
                    this.next      = candidate;
                    candidate.prev = this;
                }
                finally
                {
                    @lock.Unlock();
                }
            }
Пример #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Nullable public WeakRunnable remove(Runnable obj)
            public virtual WeakRunnable remove(IRunnable obj)
            {
                @lock.Lock();
                try
                {
                    ChainedRef curr = this.next;                     // Skipping head
                    while (curr != null)
                    {
                        if (curr.runnable == obj)
                        {                         // We do comparison exactly how Handler does inside
                            return(curr.remove());
                        }
                        curr = curr.next;
                    }
                }
                finally
                {
                    @lock.Unlock();
                }
                return(null);
            }
Пример #5
0
 public virtual WeakRunnable remove()
 {
     @lock.Lock();
     try
     {
         if (prev != null)
         {
             prev.next = next;
         }
         if (next != null)
         {
             next.prev = prev;
         }
         prev = null;
         next = null;
     }
     finally
     {
         @lock.Unlock();
     }
     return(wrapper);
 }
Пример #6
0
 private void InitializeInstanceFields()
 {
     mRunnables = new ChainedRef(mLock, null);
 }