mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-06 12:43:46 +01:00
http: Add some operations to avoid blocking.
This commit is contained in:
1 parent
e4aef7209f
commit
65d072c7b0
2 files changed
+9
-3
No files matched your search
@@ -201,6 +201,11 @@ bool InputSink::Empty() {
|
||||
return valid_ == 0;
|
||||
}
|
||||
|
||||
bool InputSink::TryFill() {
|
||||
Fill();
|
||||
return !Empty();
|
||||
}
|
||||
|
||||
OutputSink::OutputSink(size_t fd) : fd_(fd), read_(0), write_(0), valid_(0) {
|
||||
fd_util::SetNonBlocking((int)fd_, true);
|
||||
}
|
||||
@@ -316,7 +321,7 @@ bool OutputSink::Block() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OutputSink::Flush() {
|
||||
bool OutputSink::Flush(bool allowBlock) {
|
||||
while (valid_ > 0) {
|
||||
size_t avail = std::min(BUFFER_SIZE - read_, valid_);
|
||||
|
||||
@@ -325,7 +330,7 @@ bool OutputSink::Flush() {
|
||||
|
||||
if (bytes == 0) {
|
||||
// This may also drain. Either way, keep looping.
|
||||
if (!Block()) {
|
||||
if (!allowBlock || !Block()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ public:
|
||||
bool Skip(size_t bytes);
|
||||
|
||||
bool Empty();
|
||||
bool TryFill();
|
||||
|
||||
private:
|
||||
void Fill();
|
||||
@@ -49,7 +50,7 @@ public:
|
||||
bool PushCRLF(const std::string &s);
|
||||
bool Printf(const char *fmt, ...);
|
||||
|
||||
bool Flush();
|
||||
bool Flush(bool allowBlock = true);
|
||||
|
||||
bool Empty();
|
||||
|
||||
|
||||
Reference in new issue
Block a user