-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
220 additions
and
125 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 |
---|---|---|
@@ -1 +1 @@ | ||
Modules:1.3.3 | ||
Modules:1.3.4 |
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
25 changes: 25 additions & 0 deletions
25
_src/Implementation/Time/Factories/PeriodicStopwatchFactory.cs
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,25 @@ | ||
using System; | ||
using System.Threading; | ||
using Infrastructure.Time; | ||
using Infrastructure.Time.Factories; | ||
|
||
namespace Implementation.Time.Factories; | ||
|
||
public class PeriodicStopwatchFactory : IPeriodicStopwatchFactory | ||
{ | ||
private readonly IStopwatch _parent; | ||
private readonly CancellationToken _token; | ||
|
||
public PeriodicStopwatchFactory(IStopwatch parent, CancellationToken token) | ||
{ | ||
_parent = parent ?? throw new ArgumentNullException(nameof(parent)); | ||
_token = token; | ||
} | ||
|
||
public IPeriodicStopwatch CreatePeriodicStopwatch(int periodInMilliseconds) | ||
{ | ||
var periodicStopwatch = new PeriodicStopwatch(_parent, periodInMilliseconds, _token); | ||
_parent.RegisterStopwatch(periodicStopwatch); | ||
return periodicStopwatch; | ||
} | ||
} |
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
8 changes: 8 additions & 0 deletions
8
_src/Infrastructure/Time/Factories/IPeriodicStopwatchFactory.cs
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,8 @@ | ||
using System.Threading; | ||
|
||
namespace Infrastructure.Time.Factories; | ||
|
||
public interface IPeriodicStopwatchFactory | ||
{ | ||
IPeriodicStopwatch CreatePeriodicStopwatch(int periodInMilliseconds); | ||
} |
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,15 @@ | ||
using System; | ||
using Infrastructure.Time.Listeners; | ||
|
||
namespace Infrastructure.Time; | ||
|
||
public interface IAdjustableStopwatch | ||
{ | ||
bool IsRunning { get; } | ||
TimeSpan Elapsed { get; } | ||
void Start(); | ||
void Stop(); | ||
void Reset(); | ||
void AttachListener(ITickListener listener); | ||
|
||
} |
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,18 +1,11 @@ | ||
using System; | ||
using Infrastructure.Time.Listeners; | ||
|
||
namespace Infrastructure.Time | ||
{ | ||
public interface IPeriodicStopwatch | ||
public interface IPeriodicStopwatch : IAdjustableStopwatch, IDisposable | ||
{ | ||
TimeSpan Elapsed { get; } | ||
|
||
void Start(); | ||
void ChangePeriod(int periodInMilliseconds); | ||
void Stop(); | ||
void Resume(); | ||
void Reset(); | ||
|
||
void AttachListener(ITickListener listener); | ||
|
||
} | ||
} |
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,24 +1,18 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Infrastructure.Time.Factories; | ||
using Infrastructure.Time.Listeners; | ||
|
||
namespace Infrastructure.Time | ||
{ | ||
public interface IStopwatch : IDisposable | ||
public interface IStopwatch : IAdjustableStopwatch, IDisposable | ||
{ | ||
bool IsRunning { get; } | ||
TimeSpan Elapsed { get; } | ||
|
||
void Wait(int periodInMilliseconds, ITickListener listener); | ||
Task WaitAsync(int periodInMilliseconds, ITickListener listener); | ||
|
||
void Start(); | ||
void Stop(); | ||
void Reset(); | ||
|
||
void PeriodicOperation(int periodInMilliseconds, ITickListener listener, CancellationToken cancellationToken); | ||
|
||
void AttachListener(ITickListener listener); | ||
IPeriodicStopwatchFactory GetPeriodicStopwatchFactory(); | ||
void RegisterStopwatch(IPeriodicStopwatch stopwatch); | ||
void UnregisterStopwatch(IPeriodicStopwatch stopwatch); | ||
} | ||
} |
Oops, something went wrong.