コード例 #1
0
        public HttpBackend(IPAddress address,
                           int port,
                           int maxKeepAlives         = 100,
                           int backlog               = 128,
                           int sessionReadBufferSize = 4096,
                           int sessionReadTimeoutMs  = 5000,
                           int sessionWriteTimeoutMs = 5000)
        {
            this.port                  = port;
            listener                   = new TcpListener(address, port);
            this.maxKeepAlives         = maxKeepAlives;
            this.backlog               = backlog;
            this.sessionReadBufferSize = sessionReadBufferSize;
            sessionReadTimeout         = TimeSpan.FromMilliseconds(sessionReadTimeoutMs);
            sessionWriteTimeout        = TimeSpan.FromMilliseconds(sessionWriteTimeoutMs);
            lifeCycleToken             = new LifeCycleToken();
            sessionTable               = new ConcurrentDictionary <long, HttpSession>();
            sessionReads               = new ConcurrentDictionary <long, long>();
            webSocketSessionTable      = new ConcurrentDictionary <long, WebSocketSession>();

            sessionExceptionCounters = new CountingDictionary <Type>();

            name = $"{GetType().Name}({address}:{port})";

            timer = new WaitableTimer(name,
                                      TimeSpan.FromSeconds(1),
                                      new [] {
                new WaitableTimer.Job(nameof(CheckSessionReadTimeouts), CheckSessionReadTimeouts)
            });
        }
コード例 #2
0
 internal static extern bool SetWaitableTimerEx(
     [In] this WaitableTimer hTimer,
     [In] ref long lpDueTime,
     [In] int lPeriod,
     [In, Optional] IntPtr pfnCompletionRoutine,
     [In, Optional] IntPtr lpArgToCompletionRoutine,
     [In, Optional] IntPtr WakeContext,
     [In] uint TolerableDelay
     );
コード例 #3
0
ファイル: IOThreadTimer.cs プロジェクト: sveinfid-prospa/wcf
            private void OnWaitCallback(object state)
            {
                WaitableTimer.WaitAny(waitableTimers);
                long now = Ticks.Now;

                lock (ThisLock)
                {
                    waitScheduled = false;
                    ScheduleElapsedTimers(now);
                    ReactivateWaitableTimers();
                    ScheduleWaitIfAnyTimersLeft();
                }
            }
コード例 #4
0
            static void UpdateWaitableTimer(TimerGroup timerGroup)
            {
                WaitableTimer waitableTimer = timerGroup.WaitableTimer;
                IOThreadTimer minTimer      = timerGroup.TimerQueue.MinTimer;
                long          timeDiff      = waitableTimer.DueTime - minTimer.dueTime;

                if (timeDiff < 0)
                {
                    timeDiff = -timeDiff;
                }
                if (timeDiff > minTimer.maxSkew)
                {
                    waitableTimer.Set(minTimer.dueTime);
                }
            }
        Router(RouteTable[] routeTables, int requestLogsSize, int timerPeriodMs)
        {
            this.routeTables = routeTables;

            rateLimitedEndpoints = routeTables.SelectMany(table => table.Where(ep => ep is RateLimitedEndpoint).Cast <RateLimitedEndpoint>())
                                   .ToArray();

            requestLogs = new RequestLogs(this, requestLogsSize);
            Metrics     = new RouterMetrics(this);
            timer       = new WaitableTimer("RouterTimer",
                                            TimeSpan.FromMilliseconds(timerPeriodMs),
                                            new [] {
                new WaitableTimer.Job("UpdateRateLimitBuckets", UpdateRateLimitBuckets),
                new WaitableTimer.Job("ProcessRequestLogs", ProcessRequestLogs)
            });
        }
コード例 #6
0
    public Waiter(ElapsedTimeCounter counter, long intervalTicks, bool highResolution)
    {
        _counter = counter ?? throw new ArgumentNullException(nameof(counter));
        if (intervalTicks < 0)
        {
            throw new ArgumentOutOfRangeException(nameof(intervalTicks));
        }
        _intervalTicks = intervalTicks;

        _handle =
            NativeMethods.CreateWaitableTimerEx(
                IntPtr.Zero,
                IntPtr.Zero,
                WaitableTimer.FLAGS.MANUAL_RESET | (highResolution ? WaitableTimer.FLAGS.HIGH_RESOLUTION : 0),
                WaitableTimer.ACCESSES.SYNCHRONIZE | WaitableTimer.ACCESSES.TIMER_ALL_ACCESS
                );

        if (_handle.IsInvalid)
        {
            throw new TimerException($"CreateWaitableTimerEx failed [{Marshal.GetLastWin32Error()}]");
        }

        Reset();
    }
コード例 #7
0
 public TimerGroup()
 {
     this.waitableTimer = new WaitableTimer();
     this.waitableTimer.Set(long.MaxValue);
     this.timerQueue = new TimerQueue();
 }
コード例 #8
0
ファイル: IOThreadTimer.cs プロジェクト: sveinfid-prospa/wcf
 public TimerGroup()
 {
     waitableTimer = new WaitableTimer();
     timerQueue    = new TimerQueue();
 }
コード例 #9
0
ファイル: IOThreadTimer.cs プロジェクト: neiz/SignalR
 public TimerGroup()
 {
     this.waitableTimer = new WaitableTimer();
     this.waitableTimer.Set(long.MaxValue);
     this.timerQueue = new TimerQueue();
 }
コード例 #10
0
 public TimerGroup()
 {
     WaitableTimer = new WaitableTimer();
     WaitableTimer.Set(long.MaxValue);
     TimerQueue = new TimerQueue();
 }
コード例 #11
0
 internal static extern int WaitForSingleObject(
     [In] this WaitableTimer hTimer,
     [In] uint dwMilliseconds
     );