-
Notifications
You must be signed in to change notification settings - Fork 863
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ITimer abstracts out a real Timer (#518)
This PR adds ITimer abstraction and makes all timer-dependent tests use it to improve their stability and performance. Fixes #508
- Loading branch information
Showing
9 changed files
with
211 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
|
||
namespace Microsoft.ReverseProxy.Utilities | ||
{ | ||
internal interface ITimer : IDisposable | ||
{ | ||
void Change(long dueTime, long period); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Threading; | ||
|
||
namespace Microsoft.ReverseProxy.Utilities | ||
{ | ||
internal interface ITimerFactory | ||
{ | ||
Timer CreateTimer(TimerCallback callback, object state, long dueTime, long period); | ||
ITimer CreateTimer(TimerCallback callback, object state, long dueTime, long period); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.Threading; | ||
|
||
namespace Microsoft.ReverseProxy.Utilities | ||
{ | ||
internal class TimerWrapper : ITimer | ||
{ | ||
private readonly Timer _realTimer; | ||
|
||
public TimerWrapper(TimerCallback callback, object state, long dueTime, long period) | ||
{ | ||
_realTimer = new Timer(callback, state, dueTime, period); | ||
} | ||
|
||
public void Change(long dueTime, long period) | ||
{ | ||
_realTimer.Change(dueTime, period); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_realTimer.Dispose(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.