diff options
author | crupest <crupest@outlook.com> | 2024-06-24 00:06:25 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2024-10-06 18:03:42 +0800 |
commit | b2a331aa527bdd5f4d91727904cc5c66fe897d62 (patch) | |
tree | e84d0bfdd4ed63255024e02954963d8c564ad024 /include/cru | |
parent | dfe62dcf8bcefc523b466e127c3edc4dc2756629 (diff) | |
download | cru-b2a331aa527bdd5f4d91727904cc5c66fe897d62.tar.gz cru-b2a331aa527bdd5f4d91727904cc5c66fe897d62.tar.bz2 cru-b2a331aa527bdd5f4d91727904cc5c66fe897d62.zip |
Done Stream refactor.
NEED TEST: BufferStream, AutoReadStream, SubProcess.
Diffstat (limited to 'include/cru')
-rw-r--r-- | include/cru/base/io/AutoReadStream.h | 6 | ||||
-rw-r--r-- | include/cru/base/io/Stream.h | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/include/cru/base/io/AutoReadStream.h b/include/cru/base/io/AutoReadStream.h index 759d5026..56e2beca 100644 --- a/include/cru/base/io/AutoReadStream.h +++ b/include/cru/base/io/AutoReadStream.h @@ -39,7 +39,7 @@ class CRU_BASE_API AutoReadStream : public Stream { * @param options Options to modify the behavior. */ AutoReadStream( - Stream* stream, bool auto_delete, + Stream* stream, bool auto_close, bool auto_delete, const AutoReadStreamOptions& options = AutoReadStreamOptions()); ~AutoReadStream() override; @@ -47,7 +47,7 @@ class CRU_BASE_API AutoReadStream : public Stream { public: CRU_STREAM_IMPLEMENT_CLOSE_BY_DO_CLOSE - void BeginToDrop(bool auto_delete = true); + void BeginToDrop(bool auto_close = true, bool auto_delete = true); protected: Index DoRead(std::byte* buffer, Index offset, Index size) override; @@ -61,11 +61,11 @@ class CRU_BASE_API AutoReadStream : public Stream { private: Stream* stream_; + bool auto_close_; bool auto_delete_; Index size_per_read_; std::unique_ptr<BufferStream> buffer_stream_; - std::mutex buffer_stream_mutex_; std::thread background_thread_; }; diff --git a/include/cru/base/io/Stream.h b/include/cru/base/io/Stream.h index e0b61627..0965cf22 100644 --- a/include/cru/base/io/Stream.h +++ b/include/cru/base/io/Stream.h @@ -26,11 +26,11 @@ class CRU_BASE_API StreamOperationNotSupportedException : public Exception { String operation_; }; -class CRU_BASE_API StreamAlreadyClosedException : public Exception { +class CRU_BASE_API StreamClosedException : public Exception { public: - StreamAlreadyClosedException(); + StreamClosedException(); - CRU_DEFAULT_DESTRUCTOR(StreamAlreadyClosedException) + CRU_DEFAULT_DESTRUCTOR(StreamClosedException) static void Check(bool closed); }; @@ -117,7 +117,7 @@ class CRU_BASE_API Stream : public Object { bool GetClosed() { return closed_; } void SetClosed(bool closed) { closed_ = closed; } - void CheckClosed() { StreamAlreadyClosedException::Check(closed_); } + void CheckClosed() { StreamClosedException::Check(closed_); } private: std::optional<SupportedOperations> supported_operations_; |