Simplify BufferRaw constructor.

GitOrigin-RevId: 829ca6b32fc320782051b6a01a39f7290ae117ed
This commit is contained in:
levlam 2019-01-24 21:15:08 +03:00
parent c087b4bb6e
commit dd06568a48
2 changed files with 7 additions and 7 deletions

View File

@ -20,23 +20,22 @@
namespace td {
struct BufferRaw {
explicit BufferRaw(size_t size)
: data_size_(size), begin_(0), end_(0), ref_cnt_(1), has_writer_(true), was_reader_(false) {
explicit BufferRaw(size_t size) : data_size_(size) {
}
size_t data_size_;
// Constant after first reader is created.
// May be change by writer before it.
// So writer may do prepends till there is no reader created.
size_t begin_;
size_t begin_ = 0;
// Write by writer.
// Read by reader.
std::atomic<size_t> end_;
std::atomic<size_t> end_{0};
mutable std::atomic<int32> ref_cnt_;
std::atomic<bool> has_writer_;
bool was_reader_;
mutable std::atomic<int32> ref_cnt_{1};
std::atomic<bool> has_writer_{true};
bool was_reader_{false};
alignas(4) unsigned char data_[1];
};

View File

@ -20,4 +20,5 @@ Status copy_file(CSlice from, CSlice to, int64 size = -1) TD_WARN_UNUSED_RESULT;
Status write_file(CSlice to, Slice data) TD_WARN_UNUSED_RESULT;
std::string clean_filename(CSlice name);
} // namespace td