Revision ec711b23152ca4e426057557784af322a2065fbc authored by mrambacher on 17 July 2020, 02:04:44 UTC, committed by Facebook GitHub Bot on 17 July 2020, 02:06:31 UTC
Summary: This PR does a few things: - The "compression_opts" and "bottom_compression_opts" can now be read/written as name/value pairs of options (instead of only a colon-separated list; - These options can now be read/written to the Options file; - The parallel_threads value can now be set (either in the colon or name-value format). The compression options are now stored and treated as a OptionTypeInfo::Struct by the options system, meaning they can be read and written like the other structs. This change allows them to be read/written easily to the options file. Additionally, the colon-format was extended to allow support for setting parallel threads. Tests were added to test all of the option settings via the optional parameters in the colon format. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6817 Reviewed By: ajkr Differential Revision: D22396004 Pulled By: zhichao-cao fbshipit-source-id: 38bcf74b7e9cd5bc2a84540fac2e9ba4f765b2c8
1 parent c5ddece
channel.h
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
// This source code is licensed under both the GPLv2 (found in the
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).
#pragma once
#include <condition_variable>
#include <mutex>
#include <queue>
#include <utility>
namespace ROCKSDB_NAMESPACE {
template <class T>
class channel {
public:
explicit channel() : eof_(false) {}
channel(const channel&) = delete;
void operator=(const channel&) = delete;
void sendEof() {
std::lock_guard<std::mutex> lk(lock_);
eof_ = true;
cv_.notify_all();
}
bool eof() {
std::lock_guard<std::mutex> lk(lock_);
return buffer_.empty() && eof_;
}
size_t size() const {
std::lock_guard<std::mutex> lk(lock_);
return buffer_.size();
}
// writes elem to the queue
void write(T&& elem) {
std::unique_lock<std::mutex> lk(lock_);
buffer_.emplace(std::forward<T>(elem));
cv_.notify_one();
}
/// Moves a dequeued element onto elem, blocking until an element
/// is available.
// returns false if EOF
bool read(T& elem) {
std::unique_lock<std::mutex> lk(lock_);
cv_.wait(lk, [&] { return eof_ || !buffer_.empty(); });
if (eof_ && buffer_.empty()) {
return false;
}
elem = std::move(buffer_.front());
buffer_.pop();
cv_.notify_one();
return true;
}
private:
std::condition_variable cv_;
mutable std::mutex lock_;
std::queue<T> buffer_;
bool eof_;
};
} // namespace ROCKSDB_NAMESPACE
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...