basic_test<DMPMC, true>();
}
-TEST(DynamicBoundedQueue, size) {
- {
- folly::DynamicBoundedQueue<int, true, true, true> q(10);
- ASSERT_EQ(sizeof(q), 640);
- }
- {
- folly::DynamicBoundedQueue<uint64_t, false, false, false, 7, 4> q(10);
- ASSERT_EQ(sizeof(q), 80 + sizeof(folly::hazptr::hazptr_obj_batch));
- }
-}
-
template <template <typename, bool, typename> class Q, bool MayBlock>
void move_test() {
struct Foo {
* and a thread-safe access only, for now. */
class hazptr_obj_batch {
- static constexpr size_t DefaultThreshold = 20;
+ static constexpr int DefaultThreshold = 20;
hazptr_obj* head_{nullptr};
hazptr_obj* tail_{nullptr};
- size_t rcount_{0};
- size_t threshold_{DefaultThreshold};
+ int rcount_{0};
+ int threshold_{DefaultThreshold};
public:
hazptr_obj_batch() {}
- hazptr_obj_batch(hazptr_obj* head, hazptr_obj* tail, size_t rcount)
+ hazptr_obj_batch(hazptr_obj* head, hazptr_obj* tail, int rcount)
: head_(head), tail_(tail), rcount_(rcount) {}
~hazptr_obj_batch() {
}
}
- void set_threshold(size_t thresh) {
+ void set_threshold(int thresh) {
threshold_ = thresh;
}
std::atomic<hazptr_obj*> retired_ = {nullptr};
std::atomic<int> hcount_ = {0};
std::atomic<int> rcount_ = {0};
+ /* Using signed int for rcount_ because it may transiently be
+ * negative. Using signed int for all integer variables that may be
+ * involved in calculations related to the value of rcount_. */
void objRetire(hazptr_obj*);
hazptr_rec* hazptrAcquire();