AWS SDK for C++

AWS SDK for C++ Version 1.11.440

Loading...
Searching...
No Matches
ConcurrentStreamBuf.h
1
5#pragma once
6
7#include <aws/core/Core_EXPORTS.h>
8#include <aws/core/auth/AWSAuthSigner.h>
9#include <aws/common/array_list.h>
10
11#include <mutex>
12#include <condition_variable>
13#include <streambuf>
14#include <ios>
15#include <cassert>
16
17namespace Aws
18{
19 namespace Utils
20 {
21 namespace Stream
22 {
29 class AWS_CORE_API ConcurrentStreamBuf : public std::streambuf
30 {
31 public:
32
33 explicit ConcurrentStreamBuf(size_t bufferLength = 8 * 1024);
34
35 void SetEofInput(Aws::IOStream* pStreamToClose = nullptr);
37
42 bool WaitForDrain(int64_t timeoutMs);
43
44 protected:
45 std::streampos seekoff(std::streamoff off, std::ios_base::seekdir dir, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out) override;
46 std::streampos seekpos(std::streampos pos, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out) override;
47
48 int underflow() override;
49 int uflow() override;
50 int overflow(int ch) override;
51 int sync() override;
52 std::streamsize showmanyc() override;
53
55
56 private:
59 Aws::Vector<unsigned char> m_backbuf; // used to shuttle data from the put area to the get area
60 std::mutex m_lock; // synchronize access to the common backbuffer
61 std::condition_variable m_signal;
62 bool m_eofInput = false;
63 bool m_eofOutput = false;
64 Aws::IOStream* m_pStreamToClose = nullptr;
65 };
66 }
67 }
68}
std::streamsize showmanyc() override
std::streampos seekoff(std::streamoff off, std::ios_base::seekdir dir, std::ios_base::openmode which=std::ios_base::in|std::ios_base::out) override
void SetEofInput(Aws::IOStream *pStreamToClose=nullptr)
ConcurrentStreamBuf(size_t bufferLength=8 *1024)
std::streampos seekpos(std::streampos pos, std::ios_base::openmode which=std::ios_base::in|std::ios_base::out) override
bool WaitForDrain(int64_t timeoutMs)
std::basic_iostream< char, std::char_traits< char > > IOStream
std::vector< T, Aws::Allocator< T > > Vector
Definition AWSVector.h:17