using System;
using System.Threading;
using System.Threading.Tasks;
namespace ZeroLevel.Services.Shedulling
{
internal class ExpiredAsyncObject
{
private static long _counter = 0;
public ExpiredAsyncObject()
{
Key = Interlocked.Increment(ref _counter);
}
public ExpiredAsyncObject(bool has_no_key)
{
if (has_no_key)
Key = -1;
else
Key = Interlocked.Increment(ref _counter);
}
public ExpiredAsyncObject Reset(DateTime nextDate)
{
ExpirationDate = nextDate;
Next = null;
return this;
}
///
/// Action at the end of the wait
///
public Func Callback;
///
/// Expiration Timeout
///
public DateTime ExpirationDate;
///
/// Next object with the nearest waiting date
///
public ExpiredAsyncObject Next;
///
/// Key to identify the pending event
///
public long Key { get; }
}
}