You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/ZeroLevel/Services/Shedulling/ExpiredObject.cs

58 lines
1.5 KiB

6 years ago
using System;
using System.Threading;
namespace ZeroLevel.Services.Shedulling
{
/// <summary>
/// A wrapper around an Action that stores the time at which an action should be performed, as well as a link to the next action.
6 years ago
/// </summary>
internal sealed class ExpiredObject
6 years ago
{
private static long _counter = 0;
5 years ago
internal static void ResetIndex(long index)
=> _counter = index;
6 years ago
public ExpiredObject()
{
Key = Interlocked.Increment(ref _counter);
if (Key == -1)
6 years ago
Key = Interlocked.Increment(ref _counter);
}
public ExpiredObject(bool has_no_key)
{
if (has_no_key)
Key = -1;
else
Key = Interlocked.Increment(ref _counter);
}
public ExpiredObject Reset(DateTime nextDate)
{
ExpirationDate = nextDate;
7 months ago
Next = null!;
6 years ago
return this;
}
/// <summary>
/// Action at the end of the wait
6 years ago
/// </summary>
public Action<long> Callback;
6 years ago
/// <summary>
///Expiration Timeout
6 years ago
/// </summary>
public DateTime ExpirationDate;
6 years ago
/// <summary>
/// Next object with the nearest waiting date
6 years ago
/// </summary>
public ExpiredObject Next;
6 years ago
/// <summary>
/// Key to identify the pending event
6 years ago
/// </summary>
public long Key { get; }
}
}

Powered by TurnKey Linux.