https://github.com/springhgui/hashedwheeltimer
High performance and light weight HashedWheelTimer implement by c#
https://github.com/springhgui/hashedwheeltimer
hashedwheeltimer timer timingwheel wheel wheeltimer
Last synced: 4 months ago
JSON representation
High performance and light weight HashedWheelTimer implement by c#
- Host: GitHub
- URL: https://github.com/springhgui/hashedwheeltimer
- Owner: SpringHgui
- License: mit
- Created: 2023-04-13T12:10:02.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-04-18T08:14:17.000Z (almost 3 years ago)
- Last Synced: 2025-08-21T23:54:02.191Z (5 months ago)
- Topics: hashedwheeltimer, timer, timingwheel, wheel, wheeltimer
- Language: C#
- Homepage:
- Size: 48.8 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HashedWheelTimer
[](https://www.nuget.org/packages/WheelTimer/)
High performance and light weight `HashedWheelTimer` implement by c#
fork from [DotNetty](https://github.com/Azure/DotNetty/blob/dev/src/DotNetty.Common/Utilities/HashedWheelTimer.cs)
# Install nuget package
```
dotnet add package WheelTimer
```
# Usages
```c#
// 1. Inheritance interface: `ITimerTask`
// such as:
public class ActionTimerTask : ITimerTask
{
readonly Action action;
public ActionTimerTask(Action 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();
``