diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /library/cpp/coroutine/engine/iostatus.h | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) | |
download | ydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/coroutine/engine/iostatus.h')
-rw-r--r-- | library/cpp/coroutine/engine/iostatus.h | 142 |
1 files changed, 71 insertions, 71 deletions
diff --git a/library/cpp/coroutine/engine/iostatus.h b/library/cpp/coroutine/engine/iostatus.h index 8478ce05e8..bf6036805d 100644 --- a/library/cpp/coroutine/engine/iostatus.h +++ b/library/cpp/coroutine/engine/iostatus.h @@ -1,91 +1,91 @@ #pragma once - + #include <util/generic/yexception.h> -class TIOStatus { -public: +class TIOStatus { +public: TIOStatus(int status) noexcept - : Status_(status) - { - } - + : Status_(status) + { + } + static TIOStatus Error(int status) noexcept { - return TIOStatus(status); - } - + return TIOStatus(status); + } + static TIOStatus Error() noexcept { - return TIOStatus(LastSystemError()); - } - + return TIOStatus(LastSystemError()); + } + static TIOStatus Success() noexcept { - return TIOStatus(0); - } - + return TIOStatus(0); + } + void Check() const { - if (Status_) { - ythrow TSystemError(Status_) << "io error"; - } - } - + if (Status_) { + ythrow TSystemError(Status_) << "io error"; + } + } + bool Failed() const noexcept { - return (bool)Status_; - } - + return (bool)Status_; + } + bool Succeed() const noexcept { - return !Failed(); - } - + return !Failed(); + } + int Status() const noexcept { - return Status_; - } - -private: - int Status_; -}; - - -class TContIOStatus { -public: + return Status_; + } + +private: + int Status_; +}; + + +class TContIOStatus { +public: TContIOStatus(size_t processed, TIOStatus status) noexcept - : Processed_(processed) - , Status_(status) - { - } - + : Processed_(processed) + , Status_(status) + { + } + static TContIOStatus Error(TIOStatus status) noexcept { - return TContIOStatus(0, status); - } - + return TContIOStatus(0, status); + } + static TContIOStatus Error() noexcept { - return TContIOStatus(0, TIOStatus::Error()); - } - + return TContIOStatus(0, TIOStatus::Error()); + } + static TContIOStatus Success(size_t processed) noexcept { - return TContIOStatus(processed, TIOStatus::Success()); - } - + return TContIOStatus(processed, TIOStatus::Success()); + } + static TContIOStatus Eof() noexcept { - return Success(0); - } - + return Success(0); + } + ~TContIOStatus() { - } - + } + size_t Processed() const noexcept { - return Processed_; - } - + return Processed_; + } + int Status() const noexcept { - return Status_.Status(); - } - + return Status_.Status(); + } + size_t Checked() const { - Status_.Check(); - - return Processed_; - } - -private: - size_t Processed_; - TIOStatus Status_; -}; + Status_.Check(); + + return Processed_; + } + +private: + size_t Processed_; + TIOStatus Status_; +}; |