It is not possible to usefully encapsulate containers that offer STL-like interfaces (which also run unordered_map) with automatic locking, because there are race conditions associated with retrieving iterators and positions within the string, and then trying to use them in subsequent operations. If you can find some less flexible interface that suits your needs, perhaps if you include some complex operations in calls with one blocked function, then you can easily wrap the thread-protected class around the container to simplify your use .
source
share