Fixed upsert() function
[libcds.git] / readme.md
1 CDS C++ library\r
2 ===============\r
3 [![GitHub version](https://badge.fury.io/gh/khizmax%2Flibcds.svg)](http://badge.fury.io/gh/khizmax%2Flibcds)\r
4 [![License](https://img.shields.io/:license-bsd-blue.svg?style=round-square)](https://github.com/khizmax/libcds/blob/master/LICENSE)\r
5 \r
6 <!---\r
7 The build time for lib and hdr-test is exceed the limit of 50 minutes\r
8 [![Build Status](https://travis-ci.org/khizmax/libcds.svg?branch=dev)](https://travis-ci.org/khizmax/libcds)\r
9 -->\r
10 <!---\r
11 The coverity dataset is about 4G of size and about 1G in compressed state so it is a problem to upload it to the coverity server\r
12 [![Coverity Scan Build Status](https://scan.coverity.com/projects/4445/badge.svg)](https://scan.coverity.com/projects/4445)\r
13 -->\r
14 \r
15 The Concurrent Data Structures (CDS) library is a collection of concurrent containers\r
16 that don't require external (manual) synchronization for shared access, and safe memory reclamation (SMR) \r
17 algorithms like [Hazard Pointer](http://en.wikipedia.org/wiki/Hazard_pointer) \r
18 and user-space [RCU](http://en.wikipedia.org/wiki/Read-copy-update) that is used as an epoch-based SMR.\r
19 \r
20 CDS is mostly header-only template library. Only SMR core implementation is segregated to .so/.dll file.\r
21 \r
22 The library contains the implementations of the following containers:\r
23   - [lock-free](http://en.wikipedia.org/wiki/Non-blocking_algorithm) stack with optional elimination support\r
24   - several algo for lock-free queue, including classic Michael & Scott algorithm and its derivatives,\r
25     the flat combining queue, the segmented queue.\r
26   - several implementation of unordered set/map - lock-free and fine-grained lock-based\r
27   - [flat-combining] (http://mcg.cs.tau.ac.il/projects/projects/flat-combining) technique\r
28   - lock-free [skip-list](http://en.wikipedia.org/wiki/Skip_list)\r
29   - lock-free FeldmanHashMap/Set [Multi-Level Array Hash](http://samos-conference.com/Resources_Samos_Websites/Proceedings_Repository_SAMOS/2013/Files/2013-IC-20.pdf)\r
30     with thread-safe bidirectional iterator support\r
31   - Bronson's et al algorithm for fine-grained lock-based AVL tree\r
32   \r
33 Generally, each container has an intrusive and non-intrusive (STL-like) version belonging to \r
34 *cds::intrusive* and *cds::container* namespace respectively. \r
35 \r
36 Version 2.x of the library is written on C++11 and can be compiled by GCC 4.8+, clang 3.3+, Intel C++ 15+, \r
37 and MS VC++ 12 (2013) Update 4.\r
38 \r
39 Download the latest release from http://sourceforge.net/projects/libcds/files/\r
40 \r
41 See online doxygen-generated doc here: http://libcds.sourceforge.net/doc/cds-api/index.html\r
42 \r
43 Evolution of libcds (Gource visualization by Landon Wilkins): https://www.youtube.com/watch?v=FHaJvVdmJ0w\r
44 \r
45 **How to build**\r
46    - *nix: [use CMake](build/cmake/readme.md)\r
47    - Windows: use MS Visual C++ 2015 project\r
48 \r
49 **Pull request requirements**\r
50 - Pull-request to *master* branch will be unconditionally rejected\r
51 - *integration* branch is intended for pull-request. Usually, *integration* branch is the same as *master*\r
52 - *dev* branch is intended for main developing. Usually, it contains unstable code\r
53 \r
54 [![Project stats](https://www.openhub.net/p/khizmax-libcds/widgets/project_thin_badge.gif)](https://www.openhub.net/p/khizmax-libcds)\r
55 \r
56 References\r
57 ----------\r
58 *Stack*\r
59   - *TreiberStack*: [1986] R. K. Treiber. Systems programming: Coping with parallelism. Technical Report RJ 5118, IBM Almaden Research Center, April 1986.\r
60   - Elimination back-off implementation is based on idea from [2004] Danny Hendler, Nir Shavit, Lena Yerushalmi "A Scalable Lock-free Stack Algorithm"\r
61         [pdf](http://people.csail.mit.edu/shanir/publications/Lock_Free.pdf)\r
62   - *FCStack* - flat-combining wrapper for *std::stack*\r
63         \r
64 *Queue*\r
65   - *BasketQueue*: [2007] Moshe Hoffman, Ori Shalev, Nir Shavit "The Baskets Queue"\r
66         [pdf](http://people.csail.mit.edu/shanir/publications/Baskets%20Queue.pdf)\r
67   - *MSQueue*:\r
68     * [1998] Maged Michael, Michael Scott "Simple, fast, and practical non-blocking and blocking concurrent queue algorithms"\r
69         [pdf](http://www.cs.rochester.edu/~scott/papers/1996_PODC_queues.pdf)\r
70     * [2002] Maged M.Michael "Safe memory reclamation for dynamic lock-free objects using atomic reads and writes"\r
71         [pdf](http://www.research.ibm.com/people/m/michael/podc-2002.pdf)\r
72     * [2003] Maged M.Michael "Hazard Pointers: Safe memory reclamation for lock-free objects"\r
73         [pdf](http://www.research.ibm.com/people/m/michael/ieeetpds-2004.pdf)\r
74   - *RWQueue*: [1998] Maged Michael, Michael Scott "Simple, fast, and practical non-blocking and blocking concurrent queue algorithms"\r
75         [pdf](http://www.cs.rochester.edu/~scott/papers/1996_PODC_queues.pdf)\r
76   - *MoirQueue*: [2000] Simon Doherty, Lindsay Groves, Victor Luchangco, Mark Moir "Formal Verification of a practical lock-free queue algorithm"\r
77         [pdf](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.87.9954&rep=rep1&type=pdf)\r
78   - *OptimisticQueue*: [2008] Edya Ladan-Mozes, Nir Shavit "An Optimistic Approach to Lock-Free FIFO Queues"\r
79         [pdf](https://people.csail.mit.edu/edya/publications/OptimisticFIFOQueue-journal.pdf)\r
80   - *SegmentedQueue*: [2010] Afek, Korland, Yanovsky "Quasi-Linearizability: relaxed consistency for improved concurrency"\r
81         [pdf](http://mcg.cs.tau.ac.il/papers/opodis2010-quasi.pdf)\r
82   - *FCQueue* - flat-combining wrapper for *std::queue*\r
83   - *TsigasCycleQueue*: [2000] Philippas Tsigas, Yi Zhang "A Simple, Fast and Scalable Non-Blocking Concurrent FIFO Queue for Shared Memory Multiprocessor Systems"\r
84         [pdf](http://www.cse.chalmers.se/~tsigas/papers/latest-spaa01.pdf)\r
85   - *VyukovMPMCCycleQueue* Dmitry Vyukov (see http://www.1024cores.net)\r
86 \r
87 *Deque*\r
88   - flat-combining deque based on *stl::deque*\r
89 \r
90 *Map, set*\r
91   - *MichaelHashMap*: [2002] Maged Michael "High performance dynamic lock-free hash tables and list-based sets"\r
92         [pdf](http://www.research.ibm.com/people/m/michael/spaa-2002.pdf)\r
93   - *SplitOrderedList*: [2003] Ori Shalev, Nir Shavit "Split-Ordered Lists - Lock-free Resizable Hash Tables"\r
94         [pdf](http://people.csail.mit.edu/shanir/publications/Split-Ordered_Lists.pdf)\r
95   - *StripedMap*, *StripedSet*: [2008] Maurice Herlihy, Nir Shavit "The Art of Multiprocessor Programming"\r
96   - *CuckooMap*, *CuckooSet*: [2008] Maurice Herlihy, Nir Shavit "The Art of Multiprocessor Programming"\r
97   - *SkipListMap*, *SkipListSet*: [2008] Maurice Herlihy, Nir Shavit "The Art of Multiprocessor Programming"\r
98   - *FeldmanHashMap*, *FeldmanHashSet*: [2013] Steven Feldman, Pierre LaBorde, Damian Dechev "Concurrent Multi-level Arrays:\r
99         Wait-free Extensible Hash Maps". Supports **thread-safe bidirectional iterators**\r
100         [pdf](http://samos-conference.com/Resources_Samos_Websites/Proceedings_Repository_SAMOS/2013/Files/2013-IC-20.pdf)\r
101         \r
102 *Ordered single-linked list*\r
103   - *LazyList*: [2005] Steve Heller, Maurice Herlihy, Victor Luchangco, Mark Moir, William N. Scherer III, and Nir Shavit "A Lazy Concurrent List-Based Set Algorithm"\r
104         [pdf](http://people.csail.mit.edu/shanir/publications/Lazy_Concurrent.pdf)\r
105   - *MichaelList*: [2002] Maged Michael "High performance dynamic lock-free hash tables and list-based sets"\r
106         [pdf](http://www.research.ibm.com/people/m/michael/spaa-2002.pdf)\r
107 \r
108 *Priority queue*\r
109   - *MSPriorityQueue*: [1996] G.Hunt, M.Michael, S. Parthasarathy, M.Scott "An efficient algorithm for concurrent priority queue heaps"\r
110         [pdf](http://web.cse.ohio-state.edu/dmrl/papers/heap96.pdf)\r
111 \r
112 *Tree*\r
113   - *EllenBinTree*: [2010] F.Ellen, P.Fatourou, E.Ruppert, F.van Breugel "Non-blocking Binary Search Tree"\r
114         [pdf](http://www.cs.vu.nl/~tcs/cm/faith.pdf)\r
115   - *BronsonAVLTreeMap* - lock-based fine-grained AVL-tree implementation: \r
116         [2010] Nathan Bronson, Jared Casper, Hassan Chafi, Kunle Olukotun "A Practical Concurrent Binary Search Tree"\r
117         [pdf](https://ppl.stanford.edu/papers/ppopp207-bronson.pdf)\r
118 \r
119 *SMR*\r
120   - Hazard Pointers\r
121     * [2002] Maged M.Michael "Safe memory reclamation for dynamic lock-free objects using atomic reads and writes" \r
122              [pdf](http://www.research.ibm.com/people/m/michael/podc-2002.pdf)\r
123     * [2003] Maged M.Michael "Hazard Pointers: Safe memory reclamation for lock-free objects" \r
124              [pdf](http://www.research.ibm.com/people/m/michael/ieeetpds-2004.pdf)\r
125     * [2004] Andrei Alexandrescy, Maged Michael "Lock-free Data Structures with Hazard Pointers" \r
126              [pdf](http://www.researchgate.net/profile/Andrei_Alexandrescu/publication/252573326_Lock-Free_Data_Structures_with_Hazard_Pointers/links/0deec529e7804288fe000000.pdf)\r
127   - User-space RCU\r
128     * [2009] M.Desnoyers "Low-Impact Operating System Tracing" PhD Thesis,\r
129              Chapter 6 "User-Level Implementations of Read-Copy Update"\r
130              [pdf](http://www.lttng.org/files/thesis/desnoyers-dissertation-2009-12-v27.pdf)\r
131     * [2011] M.Desnoyers, P.McKenney, A.Stern, M.Dagenias, J.Walpole "User-Level\r
132              Implementations of Read-Copy Update"\r
133              [pdf](http://www.dorsal.polymtl.ca/sites/www.dorsal.polymtl.ca/files/publications/desnoyers-ieee-urcu-submitted.pdf)\r
134 \r
135 *Memory allocation*\r
136   - [2004] M.Michael "Scalable Lock-free Dynamic Memory Allocation"\r
137             [pdf](http://www.research.ibm.com/people/m/michael/pldi-2004.pdf)\r
138 \r
139 *Flat Combining* technique\r
140   - [2010] Hendler, Incze, Shavit and Tzafrir "Flat Combining and the Synchronization-Parallelism Tradeoff"\r
141             [pdf](http://www.cs.bgu.ac.il/~hendlerd/papers/flat-combining.pdf)\r