Code Monkey home page Code Monkey logo

Comments (5)

danmoseley avatar danmoseley commented on May 20, 2024

@kekekeks could you please describe your scenarios?

from dotnet-framework-early-access.

kekekeks avatar kekekeks commented on May 20, 2024

Currently we have some kind of WeakEventManager implementation that needs to enumerate all event sources to compact event handler list for dead subscribers.

The reference graph looks somewhat like this:

static variable -> ConditionalWeakTable of event sources -> SubscriptionList -> List<WeakReference> of event subscribers.

When subscriber is collected there is no way to dispose the subscription list until event is triggered or event handler is added/removed unless ConditionalWeakTable supports IEnumerable. In case of .NET Core and Mono it does. We want to be able to use the code with the legacy .NET Framework.

from dotnet-framework-early-access.

danmoseley avatar danmoseley commented on May 20, 2024

Could you construct such a table using WeakReference alone?

cc @stephentoub

https://github.com/dotnet/corefx/issues/14387

from dotnet-framework-early-access.

kekekeks avatar kekekeks commented on May 20, 2024

ConditionalWeakTable is more GC efficient since it uses DependentHandle: GC is aware that it can mark the the associated value as unused alongside with the key. Implementing a custom table with WeakReference as keys would cause more objects to survive through the collection and be promoted to the next GC generation which is not a desirable behaviour.

from dotnet-framework-early-access.

danmoseley avatar danmoseley commented on May 20, 2024

@kekekeks thanks for the suggestion. We have discussed this and do not plan to do the port. We do not believe the value and need is high enough to justify the cost and risk.

from dotnet-framework-early-access.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.