mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-15 14:06:37 +08:00
1. 修改了Serein.Library中的ObjectPool工具类,提供了对象归还的默认处理方法(通过构造方法指定Action<T>委托)
2. 不再显式调用流程上下文的Reset()方法,而改为通过对象池调用 3. 同样的,对于同样使用了ObjectPool管理上下文的Serein.Proto.WebSocket项目而言,也进行了同2.一样的修改
This commit is contained in:
@@ -197,7 +197,6 @@ namespace Serein.NodeFlow.Services
|
||||
var context = pool.Allocate();
|
||||
var instance = ioc.Get(md.ActingInstanceType);
|
||||
await dd.InvokeAsync(instance, [context]);
|
||||
context.Reset();
|
||||
pool.Free(context);
|
||||
}
|
||||
ioc.Build(); // 绑定初始化时注册的类型
|
||||
@@ -225,7 +224,6 @@ namespace Serein.NodeFlow.Services
|
||||
var context = pool.Allocate();
|
||||
var instance = ioc.Get(md.ActingInstanceType);
|
||||
await dd.InvokeAsync(instance, [context]);
|
||||
context.Reset();
|
||||
pool.Free(context);
|
||||
}
|
||||
ioc.Build(); // 绑定初始化时注册的类型
|
||||
@@ -255,7 +253,6 @@ namespace Serein.NodeFlow.Services
|
||||
var context = pool.Allocate();
|
||||
var instance = ioc.Get(md.ActingInstanceType);
|
||||
await dd.InvokeAsync(instance, [context]);
|
||||
context.Reset();
|
||||
pool.Free(context);
|
||||
}
|
||||
|
||||
@@ -304,7 +301,6 @@ namespace Serein.NodeFlow.Services
|
||||
var token = WorkOptions.CancellationTokenSource.Token;
|
||||
var context = pool.Allocate();
|
||||
await startNode.StartFlowAsync(context, token);
|
||||
context.Reset();
|
||||
pool.Free(context);
|
||||
return;
|
||||
}
|
||||
@@ -330,7 +326,6 @@ namespace Serein.NodeFlow.Services
|
||||
var result = await startNode.StartFlowAsync(context, WorkOptions.CancellationTokenSource.Token); // 开始运行时从选定节点开始运行
|
||||
checkpoints["执行流程"] = sw.Elapsed;
|
||||
|
||||
context.Reset();
|
||||
pool.Free(context);
|
||||
checkpoints["释放Context"] = sw.Elapsed;
|
||||
|
||||
@@ -437,8 +432,6 @@ namespace Serein.NodeFlow.Services
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
context.Reset();
|
||||
pool.Free(context);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user