X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2Fconcurrency%2Fdetail%2FAtomicSharedPtr-detail.h;h=90d6835f3d4f7e23982d07a7ba43c333b7c757d1;hb=6824c36bf128aa415a802b66e93a5019b8e16c25;hp=02d8be02ca5daa38c42be0206f5fd7277e610501;hpb=4591832b4885f166236acee689dd2b11e3b3135b;p=folly.git diff --git a/folly/concurrency/detail/AtomicSharedPtr-detail.h b/folly/concurrency/detail/AtomicSharedPtr-detail.h index 02d8be02..90d6835f 100644 --- a/folly/concurrency/detail/AtomicSharedPtr-detail.h +++ b/folly/concurrency/detail/AtomicSharedPtr-detail.h @@ -17,9 +17,19 @@ #include #include +#include + namespace folly { namespace detail { +// This implementation is specific to libstdc++, now accepting +// diffs for other libraries. + +// Specifically, this adds support for two things: +// 1) incrementing/decrementing the shared count by more than 1 at a time +// 2) Getting the thing the shared_ptr points to, which may be different from +// the aliased pointer. + class shared_ptr_internals { public: template @@ -42,6 +52,11 @@ class shared_ptr_internals { } static void inc_shared_count(counted_base* base, long count) { + // Check that we don't exceed the maximum number of atomic_shared_ptrs. + // Consider setting EXTERNAL_COUNT lower if this CHECK is hit. + FOLLY_SAFE_CHECK( + base->_M_get_use_count() + count < INT_MAX, + "atomic_shared_ptr overflow"); __gnu_cxx::__atomic_add_dispatch( &(base->*fieldPtr(access_use_count{})), count); }