Skip to content

Commit 38d01f4

Browse files
committed
Tentatively enabled implicit producer reuse and updated README (see #271 and #278)
1 parent a15a723 commit 38d01f4

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ The entire queue's implementation is contained in **one header**, [`concurrentqu
9191
Simply download and include that to use the queue. The blocking version is in a separate header,
9292
[`blockingconcurrentqueue.h`][blockingconcurrentqueue.h], that depends on [`concurrentqueue.h`][concurrentqueue.h] and
9393
[`lightweightsemaphore.h`][lightweightsemaphore.h]. The implementation makes use of certain key C++11 features,
94-
so it requires a fairly recent compiler (e.g. VS2012+ or g++ 4.8; note that g++ 4.6 has a known bug with `std::atomic`
94+
so it requires a relatively recent compiler (e.g. VS2012+ or g++ 4.8; note that g++ 4.6 has a known bug with `std::atomic`
9595
and is thus not supported). The algorithm implementations themselves are platform independent.
9696

9797
Use it like you would any other templated queue, with the exception that you can use
@@ -128,8 +128,12 @@ There's usually two versions of each method, one "explicit" version that takes a
128128
per-consumer token, and one "implicit" version that works without tokens. Using the explicit methods is almost
129129
always faster (though not necessarily by a huge factor). Apart from performance, the primary distinction between them
130130
is their sub-queue allocation behaviour for enqueue operations: Using the implicit enqueue methods causes an
131-
automatically-allocated thread-local producer sub-queue to be allocated (it is marked for reuse once the thread exits).
132-
Explicit producers, on the other hand, are tied directly to their tokens' lifetimes (and are also recycled as needed).
131+
automatically-allocated thread-local producer sub-queue to be allocated.
132+
Explicit producers, on the other hand, are tied directly to their tokens' lifetimes (but are recycled internally).
133+
134+
In order to avoid the number of sub-queues growing without bound, implicit producers are marked for reuse once
135+
their thread exits. However, this is not supported on all platforms. If using the queue from short-lived threads,
136+
it is recommended to use explicit producer tokens instead.
133137

134138
Full API (pseudocode):
135139

concurrentqueue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ namespace moodycamel { namespace details {
218218
// Finally, iOS/ARM doesn't have support for it either, and g++/ARM allows it to compile but it's unconfirmed to actually work
219219
#if (!defined(_MSC_VER) || _MSC_VER >= 1900) && (!defined(__MINGW32__) && !defined(__MINGW64__) || !defined(__WINPTHREADS_VERSION)) && (!defined(__GNUC__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) && (!defined(__APPLE__) || !TARGET_OS_IPHONE) && !defined(__arm__) && !defined(_M_ARM) && !defined(__aarch64__)
220220
// Assume `thread_local` is fully supported in all other C++11 compilers/platforms
221-
//#define MOODYCAMEL_CPP11_THREAD_LOCAL_SUPPORTED // always disabled for now since several users report having problems with it on
221+
#define MOODYCAMEL_CPP11_THREAD_LOCAL_SUPPORTED // tentatively enabled for now; years ago several users report having problems with it on
222222
#endif
223223
#endif
224224
#endif

0 commit comments

Comments
 (0)