I'm looking for a lock-free data structure in C++ to replace the following:
pthread_mutex_lock(plock);
set.insert(element);
pthread_mutex_unlock(plock);
The set should support .insert()
and .size()
with at most O(logN) complexity, has an iterator, and should be able to keep its order with a custom comparator. Basically something that does the same as the ConcurrentSkipListSet
in Java. Ideally, it should be platform independent.
I am looking at CDS: http://libcds.sourceforge.net/doc/cds-api/modules.html but not sure which data structure can achieve the goal. The doc does not really have complexity for some of the data structures.
Any suggestion would be great, thanks!