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

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