2 ms·
Yeah this can be a hard problem to solve. In most managed languages to 'properly' deal with it you typically need to accept locking on some level (like with Co
by to11mtm 5y ago
Yeah this can be a hard problem to solve.
In most managed languages to 'properly' deal with it you typically need to accept locking on some level (like with ConcurrentDictionary in C# or ConcurrentHashMap in Java).
One semi-elegant (yet internally complex) solution I've seen; in C# there is the language-ext library. All the collection types are structs (value types where things like .Add() return a new struct) however the struct itself just holds an implementation to a class. This works well from a user standpoint but the internals of the code is... interesting to say the least and can still lead to a lot of allocations if you're not careful.