In addition to the very useful classes in System.Collections.Concurrent , one standard method in scripts with most read-rarely-changes (or, if there are frequent, but non-competitive entries) that also apply to .Net Copy-to-Write .
It has several properties that are desirable in highly competitive programs:
- instances of collection objects themselves are immutable (that is, thread-safe, you can safely list without blocking).
- it may take as long as it takes, performance and concurrency reads will not be affected
- can be implemented as a whole to turn any data structure that is not thread safe into
Limitation: if there are parallel recordings, you may have to repeat the changes, therefore, the more simultaneous recordings, the less effective they become. (What an upbeat concurrency at work)
Change Scott Chamberlain's comment reminded me that there is another limitation: if your data structures are huge and changes often occur, then copy-all-to-write can be prohibitive both in terms of memory consumption and processor cost when copying.
Eugene Beresovsky Jun 11. '15 at 23:36 2015-06-11 23:36
source share