From 624f46ff6ace5dfca5dcfe2606585b3aa68ae28c Mon Sep 17 00:00:00 2001 From: Jeff Preshing Date: Thu, 18 Feb 2016 09:01:51 -0500 Subject: [PATCH 1/1] Rename SimpleRelaxed to Crude --- README.md | 11 +++++------ ...rentMap_SimpleRelaxed.h => ConcurrentMap_Crude.h} | 12 ++++++------ ...MapAdapter_SimpleRelaxed.h => MapAdapter_Crude.h} | 12 ++++++------ .../MapLinearizabilityTest/junction_userconfig.h.in | 2 +- 4 files changed, 18 insertions(+), 19 deletions(-) rename junction/{ConcurrentMap_SimpleRelaxed.h => ConcurrentMap_Crude.h} (91%) rename junction/extra/impl/{MapAdapter_SimpleRelaxed.h => MapAdapter_Crude.h} (75%) diff --git a/README.md b/README.md index 5fd67b0..195a747 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ -Junction is a library of concurrent data structures in C++. It contains three hash map implementations: +Junction is a library of concurrent data structures in C++. It contains several hash map implementations: + junction::ConcurrentMap_Crude junction::ConcurrentMap_Linear junction::ConcurrentMap_LeapFrog junction::ConcurrentMap_Grampa @@ -98,13 +99,11 @@ The `JUNCTION_USERCONFIG` variable works in a similar way. As an example, take a ## Rules and Behavior -A Junction map is a lot like a big array of `std::atomic<>` variables, where the key is an index into the array, stores use `memory_order_release`, and loads use `memory_order_consume`. +A Junction map is a lot like a big array of `std::atomic<>` variables, where the key is an index into the array. More precisely: -More precisely, the following rules apply to Junction's Linear, LeapFrog and Grampa maps: - -* All of their member functions, together with their `Mutator` member functions, are atomic with respect to each other, so you can safely call them from any thread without mutual exclusion. +* All of a Junction map's member functions, together with its `Mutator` member functions, are atomic with respect to each other, so you can safely call them from any thread without mutual exclusion. * If an `insert` [happens before](http://preshing.com/20130702/the-happens-before-relation/) a `get` with the same key, the `get` will return the value it inserted, except if another operation changes the value in between. Any [synchronizing operation](http://preshing.com/20130823/the-synchronizes-with-relation/) will establish this relationship. -* `insert` is a [release](http://preshing.com/20120913/acquire-and-release-semantics/) operation and `get` is a [consume](http://preshing.com/20140709/the-purpose-of-memory_order_consume-in-cpp11/) operation, so you can safely pass non-atomic information between threads using a pointer. +* For Linear, LeapFrog and Grampa maps, `insert` is a [release](http://preshing.com/20120913/acquire-and-release-semantics/) operation and `get` is a [consume](http://preshing.com/20140709/the-purpose-of-memory_order_consume-in-cpp11/) operation, so you can safely pass non-atomic information between threads using a pointer. For Crude maps, all operations are relaxed. * In the current version, you must not insert while concurrently using an `Iterator`. ## Feedback diff --git a/junction/ConcurrentMap_SimpleRelaxed.h b/junction/ConcurrentMap_Crude.h similarity index 91% rename from junction/ConcurrentMap_SimpleRelaxed.h rename to junction/ConcurrentMap_Crude.h index 269db9a..c78e4cf 100644 --- a/junction/ConcurrentMap_SimpleRelaxed.h +++ b/junction/ConcurrentMap_Crude.h @@ -10,8 +10,8 @@ See the LICENSE file for more information. ------------------------------------------------------------------------*/ -#ifndef JUNCTION_CONCURRENTMAP_SIMPLERELAXED_H -#define JUNCTION_CONCURRENTMAP_SIMPLERELAXED_H +#ifndef JUNCTION_CONCURRENTMAP_CRUDE_H +#define JUNCTION_CONCURRENTMAP_CRUDE_H #include #include @@ -19,7 +19,7 @@ namespace junction { template , class VT = DefaultValueTraits > -class ConcurrentMap_SimpleRelaxed { +class ConcurrentMap_Crude { public: typedef K Key; typedef V Value; @@ -38,14 +38,14 @@ private: ureg m_sizeMask; public: - ConcurrentMap_SimpleRelaxed(ureg capacity = DefaultCapacity) { + ConcurrentMap_Crude(ureg capacity = DefaultCapacity) { TURF_ASSERT(turf::util::isPowerOf2(capacity)); m_sizeMask = capacity - 1; m_cells = new Cell[capacity]; clear(); } - ~ConcurrentMap_SimpleRelaxed() { + ~ConcurrentMap_Crude() { delete[] m_cells; } @@ -105,4 +105,4 @@ public: } // namespace junction -#endif // JUNCTION_CONCURRENTMAP_SIMPLERELAXED_H +#endif // JUNCTION_CONCURRENTMAP_CRUDE_H diff --git a/junction/extra/impl/MapAdapter_SimpleRelaxed.h b/junction/extra/impl/MapAdapter_Crude.h similarity index 75% rename from junction/extra/impl/MapAdapter_SimpleRelaxed.h rename to junction/extra/impl/MapAdapter_Crude.h index 88a2e81..1548ff6 100644 --- a/junction/extra/impl/MapAdapter_SimpleRelaxed.h +++ b/junction/extra/impl/MapAdapter_Crude.h @@ -10,11 +10,11 @@ See the LICENSE file for more information. ------------------------------------------------------------------------*/ -#ifndef JUNCTION_EXTRA_IMPL_MAPADAPTER_SIMPLERELAXED_H -#define JUNCTION_EXTRA_IMPL_MAPADAPTER_SIMPLERELAXED_H +#ifndef JUNCTION_EXTRA_IMPL_MAPADAPTER_CRUDE_H +#define JUNCTION_EXTRA_IMPL_MAPADAPTER_CRUDE_H #include -#include +#include #include namespace junction { @@ -22,7 +22,7 @@ namespace extra { class MapAdapter { public: - static TURF_CONSTEXPR const char* MapName = "Junction SimpleRelaxed map"; + static TURF_CONSTEXPR const char* MapName = "Junction Crude map"; MapAdapter(ureg) { } @@ -42,7 +42,7 @@ public: } }; - typedef ConcurrentMap_SimpleRelaxed Map; + typedef ConcurrentMap_Crude Map; static ureg getInitialCapacity(ureg maxPopulation) { return turf::util::roundUpPowerOf2(ureg(maxPopulation * 1.25f)); @@ -52,4 +52,4 @@ public: } // namespace extra } // namespace junction -#endif // JUNCTION_EXTRA_IMPL_MAPADAPTER_SIMPLERELAXED_H +#endif // JUNCTION_EXTRA_IMPL_MAPADAPTER_CRUDE_H diff --git a/samples/MapLinearizabilityTest/junction_userconfig.h.in b/samples/MapLinearizabilityTest/junction_userconfig.h.in index 5c9739d..7380013 100644 --- a/samples/MapLinearizabilityTest/junction_userconfig.h.in +++ b/samples/MapLinearizabilityTest/junction_userconfig.h.in @@ -1 +1 @@ -#define JUNCTION_IMPL_MAPADAPTER_PATH "junction/extra/impl/MapAdapter_SimpleRelaxed.h" +#define JUNCTION_IMPL_MAPADAPTER_PATH "junction/extra/impl/MapAdapter_Crude.h" -- 2.34.1