X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FProducerConsumerQueue.h;h=69f3fd5a79019f7daeae66b6806a7df404708934;hb=321542683a01c3f334047531e9b487f047129775;hp=ff1a4fe13b3dbe35903c4adf5dee3ac0a85f10d4;hpb=22afce906d7e98d95f8c45c3301072d9fd891d41;p=folly.git diff --git a/folly/ProducerConsumerQueue.h b/folly/ProducerConsumerQueue.h index ff1a4fe1..69f3fd5a 100644 --- a/folly/ProducerConsumerQueue.h +++ b/folly/ProducerConsumerQueue.h @@ -1,5 +1,5 @@ /* - * Copyright 2014 Facebook, Inc. + * Copyright 2016 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,8 +26,6 @@ #include #include #include -#include -#include namespace folly { @@ -36,9 +34,12 @@ namespace folly { * without locks. */ template -struct ProducerConsumerQueue : private boost::noncopyable { +struct ProducerConsumerQueue { typedef T value_type; + ProducerConsumerQueue(const ProducerConsumerQueue&) = delete; + ProducerConsumerQueue& operator = (const ProducerConsumerQueue&) = delete; + // size must be >= 2. // // Also, note that the number of usable slots in the queue at any @@ -60,9 +61,9 @@ struct ProducerConsumerQueue : private boost::noncopyable { // We need to destruct anything that may still exist in our queue. // (No real synchronization needed at destructor time: only one // thread can be doing this.) - if (!boost::has_trivial_destructor::value) { - int read = readIndex_; - int end = writeIndex_; + if (!std::is_trivially_destructible::value) { + size_t read = readIndex_; + size_t end = writeIndex_; while (read != end) { records_[read].~T(); if (++read == size_) { @@ -168,8 +169,8 @@ private: const uint32_t size_; T* const records_; - std::atomic readIndex_; - std::atomic writeIndex_; + std::atomic readIndex_; + std::atomic writeIndex_; }; }