input/InputStreams: pass std::unique_lock<> to various methods

This commit is contained in:
Max Kellermann
2019-04-26 19:19:45 +02:00
parent 040573c636
commit 1b5c1f75a4
33 changed files with 212 additions and 156 deletions

View File

@@ -271,9 +271,11 @@ public:
*
* Throws std::runtime_error on error.
*
* @param lock the locked mutex; may be used to wait on
* condition variables
* @param offset the relative offset
*/
virtual void Seek(offset_type offset);
virtual void Seek(std::unique_lock<Mutex> &lock, offset_type offset);
/**
* Wrapper for Seek() which locks and unlocks the mutex; the
@@ -285,8 +287,8 @@ public:
* Rewind to the beginning of the stream. This is a wrapper
* for Seek(0, error).
*/
void Rewind() {
Seek(0);
void Rewind(std::unique_lock<Mutex> &lock) {
Seek(lock, 0);
}
void LockRewind() {
@@ -296,8 +298,9 @@ public:
/**
* Skip input bytes.
*/
void Skip(offset_type _offset) {
Seek(GetOffset() + _offset);
void Skip(std::unique_lock<Mutex> &lock,
offset_type _offset) {
Seek(lock, GetOffset() + _offset);
}
void LockSkip(offset_type _offset);
@@ -351,12 +354,15 @@ public:
*
* Throws std::runtime_error on error.
*
* @param lock the locked mutex; may be used to wait on
* condition variables
* @param ptr the buffer to read into
* @param size the maximum number of bytes to read
* @return the number of bytes read
*/
gcc_nonnull_all
virtual size_t Read(void *ptr, size_t size) = 0;
virtual size_t Read(std::unique_lock<Mutex> &lock,
void *ptr, size_t size) = 0;
/**
* Wrapper for Read() which locks and unlocks the mutex;
@@ -379,7 +385,7 @@ public:
* @return true if the whole data was read, false otherwise.
*/
gcc_nonnull_all
void ReadFull(void *ptr, size_t size);
void ReadFull(std::unique_lock<Mutex> &lock, void *ptr, size_t size);
/**
* Wrapper for ReadFull() which locks and unlocks the mutex;