-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/advanced tick listener #36
Conversation
WalkthroughThe recent updates involve enhancements to the stopwatch functionality in a software system, focusing on distinguishing between multiple stopwatches triggering events. Key changes include the addition of named operations and the ability to pass more detailed information during event triggers, specifically identifying the initiating stopwatch. Changes
Assessment against linked issues
Poem
Recent Review DetailsConfiguration used: CodeRabbit UI Files selected for processing (8)
Additional comments not posted (6)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
public void RaiseTick(IStopwatch initiator, string name, int round) | ||
{ | ||
Console.WriteLine($"{Name} -> {round}, time: {ElapsedTime}, initiator: {initiator}, name: {name}"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new RaiseTick
method in DummyListener
class correctly handles additional parameters for enhanced logging and tracing. Ensure to add unit tests to verify this new functionality.
Would you like me to help with writing these unit tests or should I open a GitHub issue to track this task?
public bool IsRunning => Parent.IsRunning; | ||
public IStopwatch Parent { get; } | ||
public string Name { get; } | ||
public TimeSpan Elapsed { get; private set; } | ||
|
||
public PeriodicStopwatch(IStopwatch parent, int periodInMilliseconds, ITickListener listener, CancellationToken cancellationToken) | ||
public PeriodicStopwatch(string name, IStopwatch parent, int periodInMilliseconds, ITickListener listener, | ||
CancellationToken cancellationToken) | ||
{ | ||
_parent = parent ?? throw new ArgumentNullException(nameof(parent)); | ||
Parent = parent ?? throw new ArgumentNullException(nameof(parent)); | ||
_periodInMilliseconds = periodInMilliseconds; | ||
_cancellationToken = cancellationToken; | ||
_stopwatch = new Stopwatch(); | ||
_listeners = new List<ITickListener>(); | ||
_listeners.Add(listener); | ||
Name = name; | ||
} | ||
|
||
public PeriodicStopwatch(string name, IStopwatch parent, int periodInMilliseconds, CancellationToken cancellationToken) | ||
{ | ||
_periodInMilliseconds = periodInMilliseconds; | ||
_cancellationToken = cancellationToken; | ||
Parent = parent ?? throw new ArgumentNullException(nameof(parent)); | ||
_stopwatch = new Stopwatch(); | ||
_listeners = new List<ITickListener>(); | ||
Name = name; | ||
} | ||
|
||
public PeriodicStopwatch(IStopwatch parent, int periodInMilliseconds, CancellationToken cancellationToken) | ||
{ | ||
Parent = parent ?? throw new ArgumentNullException(nameof(parent)); | ||
_periodInMilliseconds = periodInMilliseconds; | ||
_cancellationToken = cancellationToken; | ||
_stopwatch = new Stopwatch(); | ||
_listeners = new List<ITickListener>(); | ||
Name = Guid.NewGuid().ToString(); | ||
} | ||
|
||
public PeriodicStopwatch(IStopwatch parent, int periodInMilliseconds, ITickListener listener, | ||
CancellationToken cancellationToken) | ||
{ | ||
Parent = parent ?? throw new ArgumentNullException(nameof(parent)); | ||
_periodInMilliseconds = periodInMilliseconds; | ||
_cancellationToken = cancellationToken; | ||
_parent = parent ?? throw new ArgumentNullException(nameof(parent)); | ||
_stopwatch = new Stopwatch(); | ||
_listeners = new List<ITickListener>(); | ||
_listeners.Add(listener); | ||
Name = Guid.NewGuid().ToString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The updates to the PeriodicStopwatch
class, including the addition of Parent
and Name
properties and modifications to the constructors, enhance the class's functionality and maintainability. Ensure to add unit tests to verify the behavior of these new properties and constructors.
Would you like me to help with writing these unit tests or should I open a GitHub issue to track this task?
Closes #33
Summary by CodeRabbit
New Features
Refactor
Tests
Documentation