input/async: eliminate attribute "postponed_error"

Switch the remaining users to "postponed_exception".
This commit is contained in:
Max Kellermann 2016-09-09 18:49:21 +02:00
parent 7acd91331c
commit 13259225c2
2 changed files with 8 additions and 32 deletions

View File

@ -24,6 +24,8 @@
#include "thread/Cond.hxx"
#include "IOThread.hxx"
#include <stdexcept>
#include <assert.h>
#include <string.h>
@ -64,16 +66,6 @@ AsyncInputStream::Pause()
paused = true;
}
void
AsyncInputStream::PostponeError(Error &&error)
{
assert(io_thread_inside());
seek_state = SeekState::NONE;
postponed_error = std::move(error);
cond.broadcast();
}
inline void
AsyncInputStream::Resume()
{
@ -87,7 +79,7 @@ AsyncInputStream::Resume()
}
bool
AsyncInputStream::Check(Error &error)
AsyncInputStream::Check(Error &)
{
if (postponed_exception) {
auto e = std::move(postponed_exception);
@ -95,13 +87,7 @@ AsyncInputStream::Check(Error &error)
std::rethrow_exception(e);
}
bool success = !postponed_error.IsDefined();
if (!success) {
error = std::move(postponed_error);
postponed_error.Clear();
}
return success;
return true;
}
bool
@ -121,10 +107,8 @@ AsyncInputStream::Seek(offset_type new_offset, Error &error)
/* no-op */
return true;
if (!IsSeekable()) {
error.Set(input_domain, "Not seekable");
return false;
}
if (!IsSeekable())
throw std::runtime_error("Not seekable");
/* check if we can fast-forward the buffer */
@ -187,8 +171,7 @@ AsyncInputStream::ReadTag()
bool
AsyncInputStream::IsAvailable()
{
return postponed_error.IsDefined() ||
postponed_exception ||
return postponed_exception ||
IsEOF() ||
!buffer.IsEmpty();
}
@ -289,6 +272,7 @@ AsyncInputStream::DeferredSeek()
DoSeek(seek_offset);
} catch (...) {
seek_state = SeekState::NONE;
postponed_exception = std::current_exception();
cond.broadcast();
}

View File

@ -24,7 +24,6 @@
#include "event/DeferredCall.hxx"
#include "util/HugeAllocator.hxx"
#include "util/CircularBuffer.hxx"
#include "util/Error.hxx"
#include <exception>
@ -67,8 +66,6 @@ class AsyncInputStream : public InputStream {
offset_type seek_offset;
protected:
Error postponed_error;
std::exception_ptr postponed_exception;
public:
@ -116,11 +113,6 @@ protected:
open = false;
}
/**
* Pass an error from the I/O thread to the client thread.
*/
void PostponeError(Error &&error);
bool IsBufferEmpty() const {
return buffer.IsEmpty();
}