/* * Copyright 2019 The WebRTC Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
#include"rtc_base/memory/fifo_buffer.h"
#include <algorithm>
#include"rtc_base/thread.h"
namespace rtc {
FifoBuffer::FifoBuffer(size_t size)
: state_(SS_OPEN),
buffer_(newchar[size]),
buffer_length_(size),
data_length_(0),
read_position_(0),
owner_(Thread::Current()) { // all events are done on the owner_ thread
}
FifoBuffer::FifoBuffer(size_t size, Thread* owner)
: state_(SS_OPEN),
buffer_(newchar[size]),
buffer_length_(size),
data_length_(0),
read_position_(0),
owner_(owner) { // all events are done on the owner_ thread
}
if (result == SR_SUCCESS) { // If read was successful then adjust the read position and number of // bytes buffered.
read_position_ = (read_position_ + copy) % buffer_length_;
data_length_ -= copy;
bytes_read = copy;
// if we were full before, and now we're not, post an event if (!was_writable && copy > 0) {
PostEvent(SE_WRITE, 0);
}
} return result;
}
if (result == SR_SUCCESS) { // If write was successful then adjust the number of readable bytes.
data_length_ += copy;
bytes_written = copy; // if we didn't have any data to read before, and now we do, post an event if (!was_readable && copy > 0) {
PostEvent(SE_READ, 0);
}
} return result;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.