You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Reacted by Christopher Currens, Tobias Käs and GSPP
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.
Activity
jfrijters commentedon Jul 4, 2016
+1 It is a shame to have such a powerful feature and not expose it.
weltkante commentedon Sep 4, 2019
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.
jkotas commentedon Sep 4, 2019
Formal API proposal: https://github.com/dotnet/corefx/issues/40805