proxygen
folly::io::test::RandomDataHolder Class Reference
Inheritance diagram for folly::io::test::RandomDataHolder:
folly::io::test::DataHolder

Public Member Functions

 RandomDataHolder (size_t sizeLog2)
 
- Public Member Functions inherited from folly::io::test::DataHolder
uint64_t hash (size_t size) const
 
ByteRange data (size_t size) const
 

Additional Inherited Members

- Protected Member Functions inherited from folly::io::test::DataHolder
 DataHolder (size_t sizeLog2)
 
- Protected Attributes inherited from folly::io::test::DataHolder
const size_t size_
 
std::unique_ptr< uint8_t[]> data_
 
std::unordered_map< uint64_t, uint64_thashCache_
 

Detailed Description

Definition at line 91 of file CompressionTest.cpp.

Constructor & Destructor Documentation

folly::io::test::RandomDataHolder::RandomDataHolder ( size_t  sizeLog2)
explicit

Definition at line 96 of file CompressionTest.cpp.

References folly::io::test::DataHolder::data_, i, folly::randomNumberSeed(), rng, seed, start, folly::pushmi::detail::t, threads, and uint32_t.

96  : DataHolder(sizeLog2) {
97  static constexpr size_t numThreadsLog2 = 3;
98  static constexpr size_t numThreads = size_t(1) << numThreadsLog2;
99 
101 
102  std::vector<std::thread> threads;
103  threads.reserve(numThreads);
104  for (size_t t = 0; t < numThreads; ++t) {
105  threads.emplace_back([this, seed, t, sizeLog2] {
106  std::mt19937 rng(seed + t);
107  size_t countLog2 = sizeLog2 - numThreadsLog2;
108  size_t start = size_t(t) << countLog2;
109  for (size_t i = 0; i < countLog2; ++i) {
110  this->data_[start + i] = rng();
111  }
112  });
113  }
114 
115  for (auto& t : threads) {
116  t.join();
117  }
118 }
static const int seed
std::vector< std::thread::id > threads
auto rng
Definition: CollectTest.cpp:31
auto start
std::unique_ptr< uint8_t[]> data_
uint32_t randomNumberSeed()
Definition: Random.h:367

The documentation for this class was generated from the following file: