12using namespace css::uno;
40 const Reference<XInputStream>& xSrcStream,
41 sal_Int64 nStreamSize)
42: mxSrcStream( xSrcStream )
44, mnStreamSize( nStreamSize )
46, mxUnzippingThread( new UnzippingThread(*this) )
47, mbTerminateThread( false )
65 sal_Int64 nTotalBytesRead(0);
95 if( nBufSize <= 0 || mnOffset >= nBufSize )
135 const sal_Int32 nAvailableSize =
static_cast< sal_Int32
> ( std::min< sal_Int64 >( nBytesToRead,
remainingSize() ) );
136 rData.realloc( nAvailableSize );
137 auto pData = rData.getArray();
138 sal_Int32
i = 0, nPendingBytes = nAvailableSize;
140 while( nPendingBytes )
143 if( !pBuffer.hasElements() )
145 rData.realloc( nAvailableSize - nPendingBytes );
146 return nAvailableSize - nPendingBytes;
148 const sal_Int32 limit = std::min<sal_Int32>( nPendingBytes, pBuffer.getLength() -
mnOffset );
152 nPendingBytes -= limit;
158 return nAvailableSize;
169 Sequence < sal_Int8 > aSequence( nBytesToSkip );
css::uno::Sequence< sal_Int8 > Buffer
void saveException(const std::exception_ptr &exception)
virtual void SAL_CALL skipBytes(sal_Int32 nBytesToSkip) override
std::condition_variable maBufferConsumeResume
mutex protecting Buffer queues.
Buffer maInUseBuffer
available size of stream
virtual sal_Int32 SAL_CALL available() override
std::mutex maBufferProtector
const Buffer & getNextBlock()
Fetches next available block from maPendingBuffers for use in Reading thread.
XBufferedThreadedStream(const css::uno::Reference< XInputStream > &xSrcStream, sal_Int64 nStreamSize)
sal_Int64 remainingSize() const
sal_Int64 mnStreamSize
position in stream
virtual sal_Int32 SAL_CALL readBytes(css::uno::Sequence< sal_Int8 > &aData, sal_Int32 nBytesToRead) override
std::queue< Buffer > maUsedBuffers
Buffers that are available for use.
static const size_t nBufferSize
virtual void SAL_CALL closeInput() override
int mnOffset
Buffer block in use.
std::condition_variable maBufferProduceResume
void setTerminateThread()
rtl::Reference< salhelper::Thread > mxUnzippingThread
virtual ~XBufferedThreadedStream() override
virtual sal_Int32 SAL_CALL readSomeBytes(css::uno::Sequence< sal_Int8 > &aData, sal_Int32 nMaxBytesToRead) override
void produce()
Reads from UnbufferedStream in a separate thread and stores the buffer blocks in maPendingBuffers que...
const css::uno::Reference< XInputStream > mxSrcStream
std::exception_ptr maSavedException
indicates the failure of one of the threads
static const size_t nBufferLowWater
exception caught during unzipping is saved to be thrown during reading
std::queue< Buffer > maPendingBuffers
position in maInUseBuffer
std::unique_ptr< sal_Int32[]> pData
constexpr OUStringLiteral aData