4 ms·
So honestly they probably do. This is useful whenever you want to share and optionally modify some data (especially if it's large). Eg. in a multi-threaded vid
by blaisio 9y ago
So honestly they probably do. This is useful whenever you want to share and optionally modify some data (especially if it's large).
Eg. in a multi-threaded video game, for each frame, you probably have some big block of state, which some threads will mutate. Instead of making a copy of the data for every thread, you could pass around a big immutable data structure and only make copies when writing. Each thread can own their own data, so there won't be lock contention, and when all the threads are done, a quick merge operation can recombine the modified pieces back into a single block of state for the next frame.