Exemplo n.º 1
0
 protected Edge()
 {
   _sync = new object();
   _close_event = new FireOnceEvent();
   //Atomically increment and update _edge_no
   _edge_no = System.Threading.Interlocked.Increment( ref _edge_count );
   _is_closed = 0;
   _create_dt = DateTime.UtcNow;
   _last_out_packet_datetime = _create_dt.Ticks;
   _last_in_packet_datetime = _last_out_packet_datetime;
 }
Exemplo n.º 2
0
 /**
  * @param max_enqueues the maximum number of times Enqueue is allowed, after
  * that it will throw InvalidOperationException and the queue will be closed
  */
 public Channel(int max_enqueues) {
   if( max_enqueues == 0 ) {
     //This doesn't make sense
     throw new ArgumentOutOfRangeException("max_enqueues", max_enqueues, "cannot be zero");
   }
   _closed = 0;
   _queue = new Brunet.Util.LockFreeQueue<object>();
   _max_enqueues = max_enqueues;
   _enqueues = 0;
   _count = 0;
   _close_event = new FireOnceEvent();
 }
Exemplo n.º 3
0
 public void Test0() {
   FireOnceEvent feo = new FireOnceEvent();
   int[] fired = new int[1];
   fired[0] = 0;
   feo.Add( delegate(object o, EventArgs args) { fired[0] = fired[0] + 1; });
   Assert.IsTrue( feo.Fire(null, null), "First fire test" );
   Assert.IsFalse( feo.Fire(null, null), "Second fire test" );
   Assert.IsFalse( feo.Fire(null, null), "Second fire test" );
   Assert.IsFalse( feo.Fire(null, null), "Second fire test" );
   Assert.AreEqual(fired[0], 1, "Fire event test 2");
 }
Exemplo n.º 4
0
    //Non-statics...

    protected Edge()
    {
      _sync = new object();
      _close_event = new FireOnceEvent();
      _edge_no = AllocEdgeNum(this);
      _is_closed = 0;
      _create_dt = DateTime.UtcNow;
      _last_out_packet_datetime = _create_dt.Ticks;
      _last_in_packet_datetime = _last_out_packet_datetime;
    }