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

View File

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