Commit 2598a080 authored by yuyoyuppe's avatar yuyoyuppe Committed by Facebook Github Bot

Fix msvc ProducerConsumerQueue compilation and update its doc

Summary:
Compilation of basic sample from doc using VS2017 currently fails with:
```
C2327 'folly::ProducerConsumerQueue<folly::fbstring>::writeIndex_': is not a type name, static, or enumerator
```
Fixed it and updated the docs.
Closes https://github.com/facebook/folly/pull/806

Reviewed By: akrieger

Differential Revision: D7379931

Pulled By: yfeldblum

fbshipit-source-id: 6b7a72abd3324af56de355a6e65bdc7e1195596d
parent b20cd8da
...@@ -173,16 +173,16 @@ struct ProducerConsumerQueue { ...@@ -173,16 +173,16 @@ struct ProducerConsumerQueue {
} }
private: private:
using AtomicIndex = std::atomic<unsigned int>;
char pad0_[hardware_destructive_interference_size]; char pad0_[hardware_destructive_interference_size];
const uint32_t size_; const uint32_t size_;
T* const records_; T* const records_;
alignas(hardware_destructive_interference_size) alignas(hardware_destructive_interference_size) AtomicIndex readIndex_;
std::atomic<unsigned int> readIndex_; alignas(hardware_destructive_interference_size) AtomicIndex writeIndex_;
alignas(hardware_destructive_interference_size)
std::atomic<unsigned int> writeIndex_;
char pad1_[hardware_destructive_interference_size - sizeof(writeIndex_)]; char pad1_[hardware_destructive_interference_size - sizeof(AtomicIndex)];
}; };
} // namespace folly } // namespace folly
...@@ -40,7 +40,7 @@ the queue filling or staying empty for long is unlikely. ...@@ -40,7 +40,7 @@ the queue filling or staying empty for long is unlikely.
A toy example that doesn't really do anything useful: A toy example that doesn't really do anything useful:
``` Cpp ``` Cpp
folly::ProducerConsumerQueue<folly::fbstring> queue; folly::ProducerConsumerQueue<folly::fbstring> queue{size};
std::thread reader([&queue] { std::thread reader([&queue] {
for (;;) { for (;;) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment