[+] TEngineServer

[+] TEngineServer
This commit is contained in:
ALEXTANG
2023-07-13 17:17:26 +08:00
parent a69f53592e
commit 0c8f3a5f92
790 changed files with 52737 additions and 2533 deletions

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
#pragma warning disable CS8625
namespace TEngine
{
public sealed class FCancellationToken
{
private HashSet<Action> _actions = new HashSet<Action>();
public bool IsCancel => _actions == null;
public void Add(Action action)
{
_actions.Add(action);
}
public void Remove(Action action)
{
_actions.Remove(action);
}
public void Cancel()
{
if (_actions == null)
{
return;
}
var runActions = _actions;
_actions = null;
foreach (var action in runActions)
{
try
{
action.Invoke();
}
catch (Exception e)
{
Log.Error(e);
}
}
}
}
}