Switch to single-threaded epoll-based operation
This commit is contained in:
19
buffer.cc
19
buffer.cc
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user