diff --git a/xml/System.Collections.Concurrent/ConcurrentDictionary`2.xml b/xml/System.Collections.Concurrent/ConcurrentDictionary`2.xml index c2258552bf1..e7538a1e062 100644 --- a/xml/System.Collections.Concurrent/ConcurrentDictionary`2.xml +++ b/xml/System.Collections.Concurrent/ConcurrentDictionary`2.xml @@ -450,12 +450,14 @@ The function used to generate a value for an absent key The function used to generate a new value for an existing key based on the key's existing value Uses the specified functions to add a key/value pair to the if the key does not already exist, or to update a key/value pair in the if the key already exists. - The new value for the key. This will be either be the result of addValueFactory (if the key was absent) or the result of updateValueFactory (if the key was present). + The new value for the key. This will be either be the result of addValueFactory (if the key was absent) or the result of updateValueFactory (if the key was present). simultaneously on different threads, `addValueFactory` may be called multiple times, but its key/value pair might not be added to the dictionary for every call. + + For modifications and write operations to the dictionary, uses fine-grained locking to ensure thread safety. (Read operations on the dictionary are performed in a lock-free manner.) However, the `addValueFactory` and `updateValueFactory` delegates are called outside the locks to avoid the problems that can arise from executing unknown code under a lock. Therefore, is not atomic with regards to all other operations on the class. ]]> @@ -502,7 +504,7 @@ The value to be added for an absent key The function used to generate a new value for an existing key based on the key's existing value Adds a key/value pair to the if the key does not already exist, or updates a key/value pair in the by using the specified function if the key already exists. - The new value for the key. This will be either be addValue (if the key was absent) or the result of updateValueFactory (if the key was present). + The new value for the key. This will be either be addValue (if the key was absent) or the result of updateValueFactory (if the key was present). uses fine-grained locking to ensure thread safety. (Read operations on the dictionary are performed in a lock-free manner.) However, the `updateValueFactory` delegate is called outside the locks to avoid the problems that can arise from executing unknown code under a lock. Therefore, is not atomic with regards to all other operations on the class. ]]> @@ -553,14 +558,23 @@ - The type of the keys in this + The type of an argument to pass into addValueFactory and updateValueFactory. The key to be added or whose value should be updated. The function used to generate a value for an absent key. The function used to generate a new value for an existing key based on the key's existing value. An argument to pass into addValueFactory and updateValueFactory. - Adds a key/value pair to the if the key does not already exist, or updates a key/value pair in the if the key already exists. - The new value for the key. This will be either be the result of addValueFactory (if the key was absent) or the result of updateValueFactory (if the key was present). - To be added. + Uses the specified functions and argument to add a key/value pair to the if the key does not already exist, or to update a key/value pair in the if the key already exists. + The new value for the key. This will be either be the result of addValueFactory (if the key was absent) or the result of updateValueFactory (if the key was present). + + simultaneously on different threads, `addValueFactory` may be called multiple times, but its key/value pair might not be added to the dictionary for every call. + + For modifications and write operations to the dictionary, uses fine-grained locking to ensure thread safety. (Read operations on the dictionary are performed in a lock-free manner.) However, the `addValueFactory` and `updateValueFactory` delegates are called outside the locks to avoid the problems that can arise from executing unknown code under a lock. Therefore, is not atomic with regards to all other operations on the class. + + ]]> + , , or is a null reference (Nothing in Visual Basic). @@ -757,7 +771,7 @@ 4.0.10.0 - Adds a key/value pair to the if the key does not already exist. + Adds a key/value pair to the if the key does not already exist, or returns the existing value if the key exists. uses fine-grained locking to ensure thread safety. (Read operations on the dictionary are performed in a lock-free manner.) However, the `valueFactory` delegate is called outside the locks to avoid the problems that can arise from executing unknown code under a lock. Therefore, is not atomic with regards to all other operations on the class. + Since a key/value can be inserted by another thread while `valueFactory` is generating a value, you cannot trust that just because `valueFactory` executed, its produced value will be inserted into the dictionary and returned. If you call simultaneously on different threads, `valueFactory` may be called multiple times, but only one key/value pair will be added to the dictionary. The return value depends on the presence of the key in the dictionary and whether a key/value is inserted by another thread after is called but before `valueFactory` generates a value: @@ -864,7 +880,7 @@ The key of the element to add. The value to be added, if the key does not already exist. - Adds a key/value pair to the if the key does not already exist. + Adds a key/value pair to the if the key does not already exist, or returns the existing value if the key exists. The value for the key. This will be either the existing value for the key if the key is already in the dictionary, or the new value if the key was not in the dictionary. To be added. @@ -905,13 +921,30 @@ - The type of the keys in this + The type of an argument to pass into valueFactory. The key of the element to add. The function used to generate a value for the key. - An argument value to pass into name. - Adds a key/value pair to the if the key does not already exist. - The value for the key. This will be either the existing value for the key if the key is already in the dictionary, or the new value for the key as returned by if the key was not in the dictionary. - To be added. + An argument value to pass into valueFactory. + Adds a key/value pair to the by using the specified function and an argument if the key does not already exist, or returns the existing value if the key exists. + The value for the key. This will be either the existing value for the key if the key is already in the dictionary, or the new value if the key was not in the dictionary. + + uses fine-grained locking to ensure thread safety. (Read operations on the dictionary are performed in a lock-free manner.) However, the `valueFactory` delegate is called outside the locks to avoid the problems that can arise from executing unknown code under a lock. Therefore, is not atomic with regards to all other operations on the class. + + Since a key/value can be inserted by another thread while `valueFactory` is generating a value, you cannot trust that just because `valueFactory` executed, its produced value will be inserted into the dictionary and returned. If you call simultaneously on different threads, `valueFactory` may be called multiple times, but only one key/value pair will be added to the dictionary. + + The return value depends on the presence of the key in the dictionary and whether a key/value is inserted by another thread after is called but before `valueFactory` generates a value: + + | Scenario | Return value | + | -------- | ------------ | + | The key is already in the dictionary. | The existing value is returned. | + | The key is not in the dictionary. `valueFactory` generates a value. On rechecking for the key, no key is found. | The key/value is inserted into the dictionary, and the value is returned. | + | The key is not in the dictionary. `valueFactory` generates a value. While `valueFactory` is generating the value, a different thread inserts a value for the key. After `valueFactory` executes and upon rechecking for the key, the key inserted by the other thread is found. | The value inserted by the other thread is returned. | + + ]]> +