Skip to content

Commit

Permalink
Avoid changing soon-to-be-deprecated RegisterTimer method return type (
Browse files Browse the repository at this point in the history
  • Loading branch information
ReubenBond committed May 24, 2024
1 parent 1d3f7d0 commit 061f1e5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Orleans.Core.Abstractions/Core/Grain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected Grain(IGrainContext grainContext, IGrainRuntime? grainRuntime = null)
/// <param name="period">Period of subsequent timer ticks.</param>
/// <returns>Handle for this Timer.</returns>
/// <seealso cref="IDisposable"/>
protected IGrainTimer RegisterTimer(Func<object?, Task> asyncCallback, object? state, TimeSpan dueTime, TimeSpan period)
protected IDisposable RegisterTimer(Func<object?, Task> asyncCallback, object? state, TimeSpan dueTime, TimeSpan period)
{
if (asyncCallback == null)
throw new ArgumentNullException(nameof(asyncCallback));
Expand Down
4 changes: 2 additions & 2 deletions src/Orleans.Core.Abstractions/Timers/ITimerRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public interface ITimerRegistry
/// Specify <see cref="System.Threading.Timeout.InfiniteTimeSpan"/> to disable periodic signaling.
/// </param>
/// <returns>
/// An <see cref="IGrainTimer"/> instance which represents the timer.
/// An <see cref="IDisposable"/> instance which represents the timer.
/// </returns>
IGrainTimer RegisterTimer(IGrainContext grainContext, Func<object?, Task> callback, object? state, TimeSpan dueTime, TimeSpan period);
IDisposable RegisterTimer(IGrainContext grainContext, Func<object?, Task> callback, object? state, TimeSpan dueTime, TimeSpan period);
}
2 changes: 1 addition & 1 deletion src/Orleans.Runtime/Timers/TimerRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal class TimerRegistry(ILoggerFactory loggerFactory, TimeProvider timeProv
private readonly ILogger _timerLogger = loggerFactory.CreateLogger<GrainTimer>();
private readonly TimeProvider _timeProvider = timeProvider;

public IGrainTimer RegisterTimer(IGrainContext grainContext, Func<object, Task> asyncCallback, object state, TimeSpan dueTime, TimeSpan period)
public IDisposable RegisterTimer(IGrainContext grainContext, Func<object, Task> asyncCallback, object state, TimeSpan dueTime, TimeSpan period)
{
var timer = new GrainTimer(grainContext, _timerLogger, asyncCallback, state, _timeProvider);
grainContext?.GetComponent<IGrainTimerRegistry>().OnTimerCreated(timer);
Expand Down
4 changes: 2 additions & 2 deletions test/Grains/TestInternalGrains/TimerGrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public Task StartTimer(string name, TimeSpan delay)
{
logger.LogInformation("StartTimer Name={Name} Delay={Delay}", name, delay);
if (timer is not null) throw new InvalidOperationException("Expected timer to be null");
this.timer = base.RegisterTimer(TimerTick, name, delay, Constants.INFINITE_TIMESPAN); // One shot timer
this.timer = (IGrainTimer)base.RegisterTimer(TimerTick, name, delay, Constants.INFINITE_TIMESPAN); // One shot timer
this.timerName = name;

return Task.CompletedTask;
Expand All @@ -169,7 +169,7 @@ public Task StartTimer(string name, TimeSpan delay, string operationType)
logger.LogInformation("StartTimer Name={Name} Delay={Delay}", name, delay);
if (timer is not null) throw new InvalidOperationException("Expected timer to be null");
var state = Tuple.Create<string, object>(operationType, name);
this.timer = base.RegisterTimer(TimerTickAdvanced, state, delay, Constants.INFINITE_TIMESPAN); // One shot timer
this.timer = (IGrainTimer)base.RegisterTimer(TimerTickAdvanced, state, delay, Constants.INFINITE_TIMESPAN); // One shot timer
this.timerName = name;

return Task.CompletedTask;
Expand Down

0 comments on commit 061f1e5

Please sign in to comment.