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/ExpiredAsyncObject.cs

49 lines
1.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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;
}
/// <summary>
/// Событие при завершении ожидания
/// </summary>
public Func<long, Task> Callback;
/// <summary>
/// Срок истечения ожидания
/// </summary>
public DateTime ExpirationDate;
/// <summary>
/// Следующий объект с ближайшей датой окончания ожидания
/// </summary>
public ExpiredAsyncObject Next;
/// <summary>
/// Ключ для идентификации ожидающего события
/// </summary>
public long Key { get; }
}
}

Powered by TurnKey Linux.