Skip to content

Add a new API(GetOrAddSafe) for the Concurrentdictionary type? #33705

@1996v

Description

@1996v

ConcurrentDictionary is a thread safe dictionary.
When users call GetOrAdd(TKey key, Func<TKey, TValue> valueFactory) at the same time, valuefactory will execute before the dictionary is locked due to security policy, which also means that it may be expensive due to the concurrent execution of valuefactory.
If the user can ensure that the valuefactory must be a safe code (it will not conflict with the lock inside the dictionary), can an API be provided to execute the valuefactory after the dictionary lock?

ConcurrentDictionary.GetOrAdd

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions