diff options
author | unril <unril@yandex-team.ru> | 2022-02-10 16:46:05 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:05 +0300 |
commit | 3b241dd57cf58f20bbbd63fa6a0a758dbec09b68 (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream | |
parent | 11ae9eca250d0188b7962459cbc6706719e7dca9 (diff) | |
download | ydb-3b241dd57cf58f20bbbd63fa6a0a758dbec09b68.tar.gz |
Restoring authorship annotation for <unril@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream')
3 files changed, 116 insertions, 116 deletions
diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/ConcurrentStreamBuf.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/ConcurrentStreamBuf.cpp index 0ba47bd92c..3f59dbe96d 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/ConcurrentStreamBuf.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/ConcurrentStreamBuf.cpp @@ -1,109 +1,109 @@ /** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. - */ -#include <aws/core/utils/stream/ConcurrentStreamBuf.h> -#include <aws/core/utils/logging/LogMacros.h> -#include <cstdint> -#include <cassert> - -namespace Aws -{ - namespace Utils - { - namespace Stream - { - const char TAG[] = "ConcurrentStreamBuf"; - ConcurrentStreamBuf::ConcurrentStreamBuf(size_t bufferLength) : - m_putArea(bufferLength), // we access [0] of the put area below so we must initialize it. - m_eof(false) - { - m_getArea.reserve(bufferLength); - m_backbuf.reserve(bufferLength); - - char* pbegin = reinterpret_cast<char*>(&m_putArea[0]); - setp(pbegin, pbegin + bufferLength); - } - - void ConcurrentStreamBuf::SetEof() - { - { - std::unique_lock<std::mutex> lock(m_lock); - m_eof = true; - } - m_signal.notify_all(); - } - - void ConcurrentStreamBuf::FlushPutArea() - { - const size_t bitslen = pptr() - pbase(); - if (bitslen) - { - // scope the lock - { - std::unique_lock<std::mutex> lock(m_lock); + */ +#include <aws/core/utils/stream/ConcurrentStreamBuf.h> +#include <aws/core/utils/logging/LogMacros.h> +#include <cstdint> +#include <cassert> + +namespace Aws +{ + namespace Utils + { + namespace Stream + { + const char TAG[] = "ConcurrentStreamBuf"; + ConcurrentStreamBuf::ConcurrentStreamBuf(size_t bufferLength) : + m_putArea(bufferLength), // we access [0] of the put area below so we must initialize it. + m_eof(false) + { + m_getArea.reserve(bufferLength); + m_backbuf.reserve(bufferLength); + + char* pbegin = reinterpret_cast<char*>(&m_putArea[0]); + setp(pbegin, pbegin + bufferLength); + } + + void ConcurrentStreamBuf::SetEof() + { + { + std::unique_lock<std::mutex> lock(m_lock); + m_eof = true; + } + m_signal.notify_all(); + } + + void ConcurrentStreamBuf::FlushPutArea() + { + const size_t bitslen = pptr() - pbase(); + if (bitslen) + { + // scope the lock + { + std::unique_lock<std::mutex> lock(m_lock); m_signal.wait(lock, [this, bitslen]{ return m_eof || bitslen <= (m_backbuf.capacity() - m_backbuf.size()); }); if (m_eof) { return; } - std::copy(pbase(), pptr(), std::back_inserter(m_backbuf)); - } - m_signal.notify_one(); - char* pbegin = reinterpret_cast<char*>(&m_putArea[0]); - setp(pbegin, pbegin + m_putArea.size()); - } - } - - std::streampos ConcurrentStreamBuf::seekoff(std::streamoff, std::ios_base::seekdir, std::ios_base::openmode) - { - return std::streamoff(-1); // Seeking is not supported. - } - - std::streampos ConcurrentStreamBuf::seekpos(std::streampos, std::ios_base::openmode) - { - return std::streamoff(-1); // Seeking is not supported. - } - - int ConcurrentStreamBuf::underflow() - { - { - std::unique_lock<std::mutex> lock(m_lock); - m_signal.wait(lock, [this]{ return m_backbuf.empty() == false || m_eof; }); - - if (m_eof && m_backbuf.empty()) - { - return std::char_traits<char>::eof(); - } - - m_getArea.clear(); // keep the get-area from growing unbounded. - std::copy(m_backbuf.begin(), m_backbuf.end(), std::back_inserter(m_getArea)); - m_backbuf.clear(); - } - m_signal.notify_one(); - char* gbegin = reinterpret_cast<char*>(&m_getArea[0]); - setg(gbegin, gbegin, gbegin + m_getArea.size()); - return std::char_traits<char>::to_int_type(*gptr()); - } - - std::streamsize ConcurrentStreamBuf::showmanyc() - { - std::unique_lock<std::mutex> lock(m_lock); - AWS_LOGSTREAM_TRACE(TAG, "stream how many character? " << m_backbuf.size()); - return m_backbuf.size(); - } - - int ConcurrentStreamBuf::overflow(int ch) - { - const auto eof = std::char_traits<char>::eof(); - - if (ch == eof) - { - FlushPutArea(); - return eof; - } - - FlushPutArea(); + std::copy(pbase(), pptr(), std::back_inserter(m_backbuf)); + } + m_signal.notify_one(); + char* pbegin = reinterpret_cast<char*>(&m_putArea[0]); + setp(pbegin, pbegin + m_putArea.size()); + } + } + + std::streampos ConcurrentStreamBuf::seekoff(std::streamoff, std::ios_base::seekdir, std::ios_base::openmode) + { + return std::streamoff(-1); // Seeking is not supported. + } + + std::streampos ConcurrentStreamBuf::seekpos(std::streampos, std::ios_base::openmode) + { + return std::streamoff(-1); // Seeking is not supported. + } + + int ConcurrentStreamBuf::underflow() + { + { + std::unique_lock<std::mutex> lock(m_lock); + m_signal.wait(lock, [this]{ return m_backbuf.empty() == false || m_eof; }); + + if (m_eof && m_backbuf.empty()) + { + return std::char_traits<char>::eof(); + } + + m_getArea.clear(); // keep the get-area from growing unbounded. + std::copy(m_backbuf.begin(), m_backbuf.end(), std::back_inserter(m_getArea)); + m_backbuf.clear(); + } + m_signal.notify_one(); + char* gbegin = reinterpret_cast<char*>(&m_getArea[0]); + setg(gbegin, gbegin, gbegin + m_getArea.size()); + return std::char_traits<char>::to_int_type(*gptr()); + } + + std::streamsize ConcurrentStreamBuf::showmanyc() + { + std::unique_lock<std::mutex> lock(m_lock); + AWS_LOGSTREAM_TRACE(TAG, "stream how many character? " << m_backbuf.size()); + return m_backbuf.size(); + } + + int ConcurrentStreamBuf::overflow(int ch) + { + const auto eof = std::char_traits<char>::eof(); + + if (ch == eof) + { + FlushPutArea(); + return eof; + } + + FlushPutArea(); { std::unique_lock<std::mutex> lock(m_lock); if (m_eof) @@ -114,13 +114,13 @@ namespace Aws pbump(1); return ch; } - } - - int ConcurrentStreamBuf::sync() - { - FlushPutArea(); - return 0; - } - } - } -} + } + + int ConcurrentStreamBuf::sync() + { + FlushPutArea(); + return 0; + } + } + } +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/PreallocatedStreamBuf.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/PreallocatedStreamBuf.cpp index 7aaf9c82f3..f656fc8613 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/PreallocatedStreamBuf.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/PreallocatedStreamBuf.cpp @@ -16,8 +16,8 @@ namespace Aws PreallocatedStreamBuf::PreallocatedStreamBuf(unsigned char* buffer, uint64_t lengthToRead) : m_underlyingBuffer(buffer), m_lengthToRead(lengthToRead) { - char* end = reinterpret_cast<char*>(m_underlyingBuffer + m_lengthToRead); - char* begin = reinterpret_cast<char*>(m_underlyingBuffer); + char* end = reinterpret_cast<char*>(m_underlyingBuffer + m_lengthToRead); + char* begin = reinterpret_cast<char*>(m_underlyingBuffer); setp(begin, end); setg(begin, begin, end); } @@ -55,12 +55,12 @@ namespace Aws return pos_type(off_type(-1)); } - char* end = reinterpret_cast<char*>(m_underlyingBuffer + m_lengthToRead); - char* begin = reinterpret_cast<char*>(m_underlyingBuffer); + char* end = reinterpret_cast<char*>(m_underlyingBuffer + m_lengthToRead); + char* begin = reinterpret_cast<char*>(m_underlyingBuffer); if (which == std::ios_base::in) { - setg(begin, begin + static_cast<size_t>(pos), end); + setg(begin, begin + static_cast<size_t>(pos), end); } if (which == std::ios_base::out) @@ -72,4 +72,4 @@ namespace Aws } } } -} +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/SimpleStreamBuf.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/SimpleStreamBuf.cpp index 91064590a8..6e42994744 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/SimpleStreamBuf.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/SimpleStreamBuf.cpp @@ -201,7 +201,7 @@ std::streamsize SimpleStreamBuf::xsputn(const char* s, std::streamsize n) return writeCount; } -Aws::String SimpleStreamBuf::str() const +Aws::String SimpleStreamBuf::str() const { return Aws::String(m_buffer, pptr()); } @@ -236,4 +236,4 @@ void SimpleStreamBuf::str(const Aws::String& value) } } -} +} |