Boost logo

Boost :

Subject: [boost] safe::map
From: Karen Pease (karenpease_at_[hidden])
Date: 2015-12-18 06:08:13

Hi everyone - I'm new to boost-devel, and am a bit intimidated ;) I recently
finished a project and I don't know if the boost community would have any
interest in it, whether it's really "boost material" or not:

The page goes into more detail, but the short of it is: after searching and
a long conversation on StackExchange, I discovered that while there are
threadsafe ordered-map containers out there, the threadsafety was a bit
weak. For example, if you have Thread A iterating across the map and Thread
B thread just happens to delete an element as A is passing by, A's iterator
becomes invalidated and the program crashes - even in a supposedly
"threadsafe" map. For the type of multithreaded cache
that I needed, I needed a structure that had the thread safety level of a
filesystem - you know, where multiple processes can have file descriptors
open at a time and one process might even potentially
delete a file that another is accessing, without leading to a system crash.

And that's basically what I implemented: safe::map, which not only ensures
that basic operations on the container itself are threadsafe, but that
everything you do with the iterators - even deleting elements out of the
map that other iterators are pointing to - is also threadsafe. It does this
by implementing reference counting on the elements in the map and flagging
elements for deletion rather than deleting them immediately. A more
detailed description of usage, performance, implementation, use cases, etc
is on the project page. The project comes with a test suite which launches
a number of threads that endlessly randomly tweak and iterate around the
map with every function available to them.

Does this sound like something that might be useful in boost (after
whatever changes would be required)? If there's no interest, no harm done

 - kv, Karen

Boost list run by bdawes at, gregod at, cpdaniel at, john at