diff options
| -rw-r--r-- | doc/requirements/BufferedStream.md | 19 | ||||
| -rw-r--r-- | doc/requirements/UnbufferedStream.md | 19 | ||||
| -rw-r--r-- | src/kernel/NeKit/Stream.h | 17 |
3 files changed, 50 insertions, 5 deletions
diff --git a/doc/requirements/BufferedStream.md b/doc/requirements/BufferedStream.md new file mode 100644 index 00000000..1ac01a0f --- /dev/null +++ b/doc/requirements/BufferedStream.md @@ -0,0 +1,19 @@ +# BufferedStream + +## Abstract: + +One type that has to satisfy a BufferedStream operator and type. + +## Rationale: + +- HPC systems. +- I/O systems. +- HFT systems. + +## Example: + +```cpp +BStream<BOperator, BType>; +``` + +BOperator must not flush at all times, but have the option to. diff --git a/doc/requirements/UnbufferedStream.md b/doc/requirements/UnbufferedStream.md new file mode 100644 index 00000000..d3bfd8eb --- /dev/null +++ b/doc/requirements/UnbufferedStream.md @@ -0,0 +1,19 @@ +# UnbufferedStream + +## Abstract: + +One type that has to satisfy an unbuffered Stream operator and type. + +## Rationale: + +- Fast and direct-flush operations. +- High-Throughput systems. + +## Example: + +```cpp +UBStream<UBOperator, UBType>; +``` + +UBOperator must flush at all times! + diff --git a/src/kernel/NeKit/Stream.h b/src/kernel/NeKit/Stream.h index d69df6d0..ad458d5a 100644 --- a/src/kernel/NeKit/Stream.h +++ b/src/kernel/NeKit/Stream.h @@ -1,23 +1,23 @@ -// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org) +// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/ne-foss-org/nekernel #ifndef NEKIT_STREAM_H #define NEKIT_STREAM_H +#include <CompilerKit/CompilerKit.h> #include <NeKit/Config.h> #include <NeKit/Ref.h> namespace Kernel { + template <typename StreamTrait, typename Kind> class Stream final { public: explicit Stream(Ref<Stream> ref) : fStream(ref) {} - ~Stream() = default; - Stream& operator=(const Stream&) = default; - Stream(const Stream&) = default; + NE_COPY_DEFAULT(Stream) template <typename Data> friend Stream<StreamTrait, Kind>& operator>>(Stream<StreamTrait, Kind>& Ks, Ref<Data>& Buf) { @@ -27,8 +27,8 @@ class Stream final { template <typename Data> friend Stream<StreamTrait, Kind>& operator<<(Stream<StreamTrait, Kind>& Ks, Ref<Data>& Buf) { + *Ks = Ks.fStream->Out(Buf.Leak()); Ks.fKind = Buf; - Ks.fStream->Out(Buf.Leak()); return *Ks; } @@ -40,6 +40,13 @@ class Stream final { Ref<StreamTrait> fStream; Ref<Kind> fKind; }; + +template <class ST, class Kind> +using UnbufferedStream = Stream<ST, Kind>; + +template <class BST, class BKind> +using BufferedStream = Stream<BST, BKind>; + } // namespace Kernel #endif |
