lib/nfs/FileReader: pass std::span to OnNfsFileRead()
This commit is contained in:
parent
3278ad2ed8
commit
73dc8ff6bd
|
@ -71,7 +71,7 @@ protected:
|
|||
private:
|
||||
/* virtual methods from NfsFileReader */
|
||||
void OnNfsFileOpen(uint64_t size) noexcept override;
|
||||
void OnNfsFileRead(const void *data, size_t size) noexcept override;
|
||||
void OnNfsFileRead(std::span<const std::byte> src) noexcept override;
|
||||
void OnNfsFileError(std::exception_ptr &&e) noexcept override;
|
||||
};
|
||||
|
||||
|
@ -159,14 +159,14 @@ NfsInputStream::OnNfsFileOpen(uint64_t _size) noexcept
|
|||
}
|
||||
|
||||
void
|
||||
NfsInputStream::OnNfsFileRead(const void *data, size_t data_size) noexcept
|
||||
NfsInputStream::OnNfsFileRead(std::span<const std::byte> src) noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
assert(!IsBufferFull());
|
||||
assert(IsBufferFull() == (GetBufferSpace() == 0));
|
||||
AppendToBuffer(data, data_size);
|
||||
AppendToBuffer(src.data(), src.size());
|
||||
|
||||
next_offset += data_size;
|
||||
next_offset += src.size();
|
||||
|
||||
DoRead();
|
||||
}
|
||||
|
|
|
@ -239,7 +239,10 @@ NfsFileReader::OnNfsCallback(unsigned status, void *data) noexcept
|
|||
break;
|
||||
|
||||
case State::READ:
|
||||
OnNfsFileRead(data, status);
|
||||
OnNfsFileRead({
|
||||
static_cast<const std::byte *>(data),
|
||||
static_cast<std::size_t>(status),
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <exception>
|
||||
#include <span>
|
||||
#include <string>
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
@ -125,7 +126,7 @@ protected:
|
|||
*
|
||||
* This method will be called from within the I/O thread.
|
||||
*/
|
||||
virtual void OnNfsFileRead(const void *data, size_t size) noexcept = 0;
|
||||
virtual void OnNfsFileRead(std::span<const std::byte> src) noexcept = 0;
|
||||
|
||||
/**
|
||||
* An error has occurred, which can be either while waiting
|
||||
|
|
Loading…
Reference in New Issue