Skip to content

High performance and light weight HashedWheelTimer implement by c#

License

Notifications You must be signed in to change notification settings

SpringHgui/HashedWheelTimer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

a867cfc · Apr 18, 2023

History

15 Commits
Apr 13, 2023
Apr 13, 2023
Apr 13, 2023
Apr 13, 2023
Apr 13, 2023
Apr 18, 2023
Apr 13, 2023

Repository files navigation

HashedWheelTimer

Nuget

High performance and light weight HashedWheelTimer implement by c#

fork from DotNetty

Install nuget package

dotnet add package WheelTimer

Usages

// 1. Inheritance interface: `ITimerTask`
// such as:
public class ActionTimerTask : ITimerTask
{
    readonly Action<ITimeout> action;

    public ActionTimerTask(Action<ITimeout> action) => this.action = action;

    public void Run(ITimeout timeout) => this.action(timeout);
}

// 2. add ITimerTask by `NewTimeout` method
ITimer timer = new HashedWheelTimer(TimeSpan.FromMilliseconds(100), 512, -1);
ITimeout timeout = timer.NewTimeout(
    new ActionTimerTask(
        t =>
        {
           // do what you want here
        }),
    TimeSpan.FromSeconds(10));

timer.StopAsync().Wait();
``

About

High performance and light weight HashedWheelTimer implement by c#

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages