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
Keeping in mind that without an exclusive lock of some kind, the data can change from one operation to the next.
4
4
5
5
These classes are provided to help with simple operations that don't rely on lengthy exclusive locking.
6
6
7
7
Some methods are available that assist with exclusive access:
8
8
9
-
*```.IfContains(item, action)```
10
-
*```.IfNotContains(item, action)```
11
-
*```.Snapshot()```
12
-
*```.ForEach(action, useSnapshot)```
13
-
*```.Export(destination)```
14
-
*```.CopyTo(array, arrayIndex)```
15
-
*```.Modify(action)```
9
+
*`.IfContains(item, action)`
10
+
*`.IfNotContains(item, action)`
11
+
*`.Snapshot()`
12
+
*`.ForEach(action, useSnapshot)`
13
+
*`.Export(destination)`
14
+
*`.CopyTo(array, arrayIndex)`
15
+
*`.Modify(action)`
16
16
17
-
A snapshot is simply a copy of the collection at a given moment that can then be operated on while the underlying collection can continute to mutate.
17
+
A "snapshot" is simply a copy of the collection at a given moment that can then be operated on while the underlying collection can continue to mutate.
18
18
19
19
### Reads
20
20
21
-
Any operation that the collection cannot be changing (adding/removing) while executing. ie. ```.Contains(item)```
21
+
Any operation that the collection cannot be changing (adding/removing) while executing.
22
+
ie. ```.Contains(item)```
22
23
23
24
### Writes
24
25
@@ -32,14 +33,14 @@ Best to use these classes when expecting a mix of read/write but with a majority
32
33
33
34
## Read-Write Synchronized
34
35
35
-
These classes use a ReaderWriterLockSlim to synchronize read-write access and can be faster in some specific cases.
36
+
These classes use a `ReaderWriterLockSlim` to synchronize read-write access and can be faster in some specific cases.
36
37
37
-
Best to use these classes when expecting a mix of read/write but with a majority of reads.
38
+
Best to use these classes when expecting a mix of read/write but with a majority of reads and typically of a smaller size.
38
39
39
40
## Benchmarks
40
41
41
42
*Important Observations:*
42
43
43
44
* Be sure to benchmark the 'Release' configuration as the difference in performance versus 'Debug' can be dramatic.
44
45
* Observe results on different machines with different core counts.
45
-
* As collection sizes increase, performance behavior changes. For example, for smaller collection sizes (~1000 or less) Read-Write synchronization wins most of the time. But larger than that, a 'lock' for writes begins to out perform.
46
+
* As collection sizes increase, performance behavior changes. For example, for smaller collection sizes (~1000 or less) Read-Write synchronization wins most of the time. But larger than that, a 'lock' for writes begins to out perform.
0 commit comments