コード例 #1
0
ファイル: Source.cs プロジェクト: johnynek/brunet
 /**
 <summary>Unsubscribes the the IDataHandler if it is the current
 IDatahandler.</summary>
 <param name="hand">An IDataHandler that wishes to remove itself as a
 destination for data coming from this source.</param>
 */
 public void Unsubscribe(IDataHandler h) {
   Subscriber s = new Subscriber(h, null);
 //We have to lock so there is no race between the read and the write
   lock( _sync ) {
     int idx = _subs.IndexOf(s);
     _subs = Brunet.Collections.Functional.RemoveAt(_subs, idx);
   }
 }
コード例 #2
0
ファイル: Source.cs プロジェクト: johnynek/brunet
 /**
 <summary>Unsubscribes the the IDataHandler if it is the current
 IDatahandler.</summary>
 <param name="hand">An IDataHandler that wishes to remove itself as a
 destination for data coming from this source.</param>
 */
 public virtual void Unsubscribe(IDataHandler hand) {
   lock(_sync) {
     if( _sub.Handler == hand ) {
       _sub = null;
     }
     else {
       throw new Exception(String.Format("Handler: {0}, not subscribed", hand));
     }
   }
 }
コード例 #3
0
ファイル: Source.cs プロジェクト: johnynek/brunet
 /**
 <summary>Subscribes the out going data from this source to the specified
 handler.</summary>
 <param name="hand">Data that the subscriber wants passed to the handler on
 each call.</param>
 <param name="state">Data that the subscriber wants passed to the handler on
 each call.</param>
 */
 public void Subscribe(IDataHandler h, object state) {
   Subscriber s = new Subscriber(h, state);
 //We have to lock so there is no race between the read and the write
   lock( _sync ) {
     _subs = Brunet.Collections.Functional.Add(_subs, s);
   }
 }
コード例 #4
0
ファイル: Source.cs プロジェクト: johnynek/brunet
 /**
 <summary>Subscribes the out going data from this source to the specified
 handler.</summary>
 <param name="hand">Data that the subscriber wants passed to the handler on
 each call.</param>
 <param name="state">Data that the subscriber wants passed to the handler on
 each call.</param>
 */
 public virtual void Subscribe(IDataHandler hand, object state) {
   lock(_sync) {
     _sub = new Subscriber(hand, state);
   }
 }