Commit 7cd53fb4 authored by Max Kellermann's avatar Max Kellermann

ThreadInputStream: add assertions

parent 538ddf7a
...@@ -118,6 +118,8 @@ ThreadInputStream::ThreadFunc(void *ctx) ...@@ -118,6 +118,8 @@ ThreadInputStream::ThreadFunc(void *ctx)
bool bool
ThreadInputStream::Check(Error &error) ThreadInputStream::Check(Error &error)
{ {
assert(!thread.IsInside());
if (postponed_error.IsDefined()) { if (postponed_error.IsDefined()) {
error = std::move(postponed_error); error = std::move(postponed_error);
return false; return false;
...@@ -129,12 +131,16 @@ ThreadInputStream::Check(Error &error) ...@@ -129,12 +131,16 @@ ThreadInputStream::Check(Error &error)
bool bool
ThreadInputStream::IsAvailable() ThreadInputStream::IsAvailable()
{ {
assert(!thread.IsInside());
return !buffer->IsEmpty() || eof || postponed_error.IsDefined(); return !buffer->IsEmpty() || eof || postponed_error.IsDefined();
} }
inline size_t inline size_t
ThreadInputStream::Read(void *ptr, size_t read_size, Error &error) ThreadInputStream::Read(void *ptr, size_t read_size, Error &error)
{ {
assert(!thread.IsInside());
while (true) { while (true) {
if (postponed_error.IsDefined()) { if (postponed_error.IsDefined()) {
error = std::move(postponed_error); error = std::move(postponed_error);
...@@ -161,5 +167,7 @@ ThreadInputStream::Read(void *ptr, size_t read_size, Error &error) ...@@ -161,5 +167,7 @@ ThreadInputStream::Read(void *ptr, size_t read_size, Error &error)
bool bool
ThreadInputStream::IsEOF() ThreadInputStream::IsEOF()
{ {
assert(!thread.IsInside());
return eof; return eof;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment