Exemplo n.º 1
0
 //flush channel if there are possible updates to send.
 void channel_UpdateEvent(HPTimer hpTimer)
 {
     //check to see if there are possibly incomingMessages to send
     if (!sendsPending) { return; }
     // One might ask: shouldn't this be better done through the channel aggregation?
     if (lastTimeSent + updateTime.TotalMilliseconds > hpTimer.TimeInMilliseconds) { return; }
     Flush();
     lastTimeSent = hpTimer.TimeInMilliseconds;
 }
Exemplo n.º 2
0
 /// <summary>Delays the sending and receiving of incomingMessages by 'injectedDelay' milliseconds.
 /// </summary>
 /// <param name="bs">The binary connexion to use to send and receive on.</param>
 /// <param name="injectedDelay">delay time to inject</param>
 public DelayedBinaryChannel(IBinaryChannel bs, TimeSpan injectedDelay)
 {
     sendQueue = new SortedDictionary<long, byte[]>();
     dequeueQueue = new SortedDictionary<long, byte[]>();
     this.bs = bs;
     bs.MessagesReceived += BinaryNewMessageEvent;
     Messages = new List<byte[]>();
     timer = new HPTimer();
     InjectedDelay = injectedDelay;
 }
Exemplo n.º 3
0
        private static void TestPerf(String name, int iter, Messagizer m, Message msg, int n)
        {
            long t0 = HPTimer.Now();

            for (int i = 0; i < n; i++)
            {
                m.TransportMessage(null, msg);
            }

            long t1 = HPTimer.NsSince(t0);

            double timeDiff = t1 / 1000000000.0;
            double r        = n / timeDiff;

            Console.WriteLine(name + " -- iteration : " + iter + " time : " + timeDiff +
                              " count : " + n + " rate : " + r);
        }
Exemplo n.º 4
0
        private void checkTickle()
        {
            long ms = HPTimer.MillisSince(lastTickle);

            //		Log.report( "KeepAliveIdle", "ms", ms, "server", server );
            if (ms >= count * delay * 1000)
            {
                try
                {
                    //				Log.report( "KeepAliveReset", "server", server );
                    session.SessionNotify("KeepAlive resetting dead connection");
                    transport.TransportControl(TransportConsts.RESET, 0);
                }
                catch (Exception e)
                {
                    reportError(e);
                }
            }
        }
Exemplo n.º 5
0
        public override void Dispose()
        {
            running = false;
            log.Trace(this + ": disposed");

            StopListeningThread();

            Dispose(acceptors);
            acceptors = null;
            timer = null;
            base.Dispose();
        }
Exemplo n.º 6
0
 /// <summary>Creates a new Server object.</summary>
 /// <param name="sc">The server configuration object.</param>
 public Server(ServerConfiguration sc)
 {
     log = LogManager.GetLogger(GetType());
     configuration = sc;
     serverIdentity = GenerateIdentity();
     timer = new HPTimer();
 }
Exemplo n.º 7
0
 /// <summary></summary>
 public Frame(double interval)
 {
     timer = new HPTimer();
     this.Interval = interval;
 }
Exemplo n.º 8
0
 public void TestNoChangeOnUpdate()
 {
     HPTimer timer = new HPTimer();
     timer.Start();
     long ms = timer.TimeInMilliseconds;
     long ticks = timer.Ticks;
     // sleep for at least for 100 rounds of ticks
     Thread.Sleep((int)Math.Max(1, 100 * 1000 / timer.Frequency));
     Assert.AreEqual(ms, timer.TimeInMilliseconds);
     Assert.AreEqual(ticks, timer.Ticks);
 }
Exemplo n.º 9
0
 public void TestChangesOnUpdate()
 {
     HPTimer timer = new HPTimer();
     timer.Start();
     long ms = timer.TimeInMilliseconds;
     long ticks = timer.Ticks;
     // sleep for at least for 100 rounds of ticks
     Thread.Sleep((int)Math.Max(5, 100 * 1000 / timer.Frequency));
     timer.Update();
     Assert.Less(ms, timer.TimeInMilliseconds);
     Assert.Less(ticks, timer.Ticks);
     Assert.Greater(timer.Frequency / (100 * 1000), timer.ElapsedInMilliseconds);
 }
Exemplo n.º 10
0
 private void tickle()
 {
     //	lastTickle = Timer.GetNanos();
     //      lastTickle = HPTimer.Now();
     lastTickle = HPTimer.Now();
 }