/** Called by clients to register listener which are notified when the
  *  weak object is dying.
  *
  *  @param xReference a listener
  */
 public void removeReference(XReference xReference)
 {
     lock (this)
     {
         m_XReference_dispose -=
             new XReference_dispose(xReference.dispose);
     }
 }
 /** Called by clients to unregister listeners.
  *
  *  @param xReference a listener
  */
 public void addReference(XReference xReference)
 {
     lock (this)
     {
         m_XReference_dispose +=
             new XReference_dispose(xReference.dispose);
     }
 }
示例#3
0
 /** Called by the XWeak implementation (WeakBase) when it is being
     finalized.  It is only being called once.
     The registererd XReference listeners are notified. On notification
     they are  to unregister themselves. The notification is thread-safe.
     However, it is possible to add a listener during the notification
     process, which will never receive a notification.
     To prevent this, one would have to synchronize this method with 
     the addReference method. But this can result in deadlocks in a
     multithreaded environment.
 */
 internal /* non-virtual */ void referentDying()
 {
     XReference_dispose call;
     lock (this)
     {
         call = m_XReference_dispose;
         m_XReference_dispose = null;
     }
     if (null != call)
         call();
 }
        /** Called by the XWeak implementation (WeakBase) when it is being
         *  finalized.  It is only being called once.
         *  The registererd XReference listeners are notified. On notification
         *  they are  to unregister themselves. The notification is thread-safe.
         *  However, it is possible to add a listener during the notification
         *  process, which will never receive a notification.
         *  To prevent this, one would have to synchronize this method with
         *  the addReference method. But this can result in deadlocks in a
         *  multithreaded environment.
         */
        internal /* non-virtual */ void referentDying()
        {
            XReference_dispose call;

            lock (this)
            {
                call = m_XReference_dispose;
                m_XReference_dispose = null;
            }
            if (null != call)
            {
                call();
            }
        }
 /** ctor.
  *
  *  @param obj the object that is to be held weakly
  */
 public WeakAdapter(Object obj)
 {
     m_weakRef            = new WeakReference(obj);
     m_XReference_dispose = null;
 }
示例#6
0
 /** Called by clients to register listener which are notified when the
     weak object is dying.
     
     @param xReference a listener
 */
 public void removeReference( XReference xReference )
 {
     lock (this)
     {
         m_XReference_dispose -=
             new XReference_dispose( xReference.dispose );
     }
 }
示例#7
0
 /** ctor.
     
     @param obj the object that is to be held weakly
 */
 public WeakAdapter( Object obj )
 {
     m_weakRef = new WeakReference( obj );
     m_XReference_dispose = null;
 }
示例#8
0
 /** Called by clients to unregister listeners.
     
     @param xReference a listener
 */
 public void addReference( XReference xReference )
 {
     lock (this)
     {
         m_XReference_dispose +=
             new XReference_dispose( xReference.dispose );
     }
 }