Пример #1
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");
        }
Пример #2
0
 /**
  * @param max_enqueues the maximum number of times Enqueue is allowed, after
  * @param state some arbitrary object we might want later
  * that it will throw InvalidOperationException and the queue will be closed
  */
 public Channel(int max_enqueues, object state) {
   if( max_enqueues == 0 ) {
     //This doesn't make sense
     throw new ArgumentOutOfRangeException("max_enqueues", max_enqueues, "cannot be zero");
   }
   State = state;
   _closed = 0;
   _queue = new LockFreeQueue<object>();
   _max_enqueues = max_enqueues;
   _enqueues = 0;
   _count = 0;
   _close_event = new FireOnceEvent();
 }
Пример #3
0
 /**
  * @param max_enqueues the maximum number of times Enqueue is allowed, after
  * @param state some arbitrary object we might want later
  * that it will throw InvalidOperationException and the queue will be closed
  */
 public Channel(int max_enqueues, object state)
 {
     if (max_enqueues == 0)
     {
         //This doesn't make sense
         throw new ArgumentOutOfRangeException("max_enqueues", max_enqueues, "cannot be zero");
     }
     State         = state;
     _closed       = 0;
     _queue        = new LockFreeQueue <object>();
     _max_enqueues = max_enqueues;
     _enqueues     = 0;
     _count        = 0;
     _close_event  = new FireOnceEvent();
 }
Пример #4
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");
 }
Пример #5
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;
    }
Пример #6
0
 protected TaskWorker()
 {
   _finish_event = new FireOnceEvent();
 }
Пример #7
0
 protected TaskWorker()
 {
     _finish_event = new FireOnceEvent();
 }