Skip to content

Expose DependentHandle #6031

Closed
Closed

Description

@GSPP

The DependentHandle struct is a useful form of a GCHandle. Currently, it's only exposed as part of the ConditionalWeakTable class. ConditionalWeakTable is quite a heavy-weight object. It does more than is often needed. If there's only a need for a single object pair using ConditionalWeakTable seems inappropriate and quite expensive.

Also, ConditionalWeakTable is synchronized internally. This means that it does not scale across many cores. For that reason it is not a good workaround to simply maintain a global ConditionalWeakTable for the entire application.

I suggest that the DependentHandle struct is being cleaned up and exposed for public consumption. As far as I can tell only cosmetic changes need to be made to make the type "nice". A namespace change is probably in order as well. It should be placed next to GCHandle.

Activity

  1. jfrijters commented on Jul 4, 2016

    @jfrijters
    Contributor

    +1 It is a shame to have such a powerful feature and not expose it.

  2. weltkante commented on Sep 4, 2019

    @weltkante
    Contributor

    I created a proposal for implementing a ConditionalWeakReference<TKey, TValue> under dotnet/corefx#40805 (moved to corefx as dotnet/corefx#40805)

    Note that this is different from this issue requesting exposal of DepedentHandle as analogue to GCHandle, my proposal adds a new primitive analogous to WeakReference (which currently does not exist at all).

    We'll see if adding a high level primitive is more likely to be accepted than exposing an "unsafe" low level primitive, both are valuable to have, but I'd be content with a "safe" high level primitive.

  3. jkotas commented on Sep 4, 2019

    @jkotas
    Member
  4. transferred this issue fromdotnet/coreclron Jan 30, 2020
  5. added this to the Future milestone on Jan 30, 2020
  6. ghost locked as resolved and limited conversation to collaborators on Dec 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions