liquidprojections / LiquidProjections

Liquid Projections supports building and maintaining autonomous .NET projection code in an Event Sourcing architecture.
https://www.liquidprojections.net
MIT License
169 stars 25 forks source link

Reuse Task instances where possible #107

Closed tomachristian closed 6 years ago

dennisdoomen commented 6 years ago

What's the rationale for these changes? And is it safe to reuse tasks?

tomachristian commented 6 years ago

Its safe to reuse these kind of tasks, yes. It reduces allocations and thus GC time. It helps in a high throughput system where lots of such instances might be created. It's a best practice to reuse Task instances where possible, but it's not a HUGE improvement.

tomachristian commented 6 years ago

Ref: https://github.com/dotnet/roslyn/blob/master/src/Workspaces/Core/Portable/Utilities/SpecializedTasks.cs