Switch to single-threaded epoll-based operation

This commit is contained in:
Ian Gulliver
2019-05-04 07:21:52 +00:00
parent 87bc2c1611
commit ac0d3e2816
8 changed files with 95 additions and 45 deletions

View File

@@ -23,6 +23,14 @@ bool ConstBuffer::Discard(size_t len) {
return true;
}
void ConstBuffer::ResetRead() {
start_ = commit_;
}
void ConstBuffer::Commit() {
commit_ = start_;
}
Buffer::Buffer(char *buf, size_t size, size_t len)
: ConstBuffer(buf, size),
@@ -58,11 +66,12 @@ void Buffer::Wrote(size_t len) {
len_ += len;
}
void Buffer::Commit() {
if (start_ == 0) {
void Buffer::Consume() {
if (commit_ == 0) {
return;
}
memmove(buf_, &buf_[start_], len_ - start_);
len_ -= start_;
start_ = 0;
memmove(buf_, &buf_[commit_], len_ - commit_);
len_ -= commit_;
start_ -= commit_;
commit_ = 0;
}