| 1 | /** |
| 2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | * SPDX-License-Identifier: Apache-2.0. |
| 4 | */ |
| 5 | |
| 6 | #ifndef AWS_S3_PART_STREAMING_INPUT_STREAM_H |
| 7 | #define AWS_S3_PART_STREAMING_INPUT_STREAM_H |
| 8 | |
| 9 | #include <aws/s3/s3.h> |
| 10 | |
| 11 | struct aws_input_stream; |
| 12 | struct aws_s3_buffer_ticket; |
| 13 | struct aws_parallel_input_stream; |
| 14 | |
| 15 | AWS_PUSH_SANE_WARNING_LEVEL |
| 16 | AWS_EXTERN_C_BEGIN |
| 17 | |
| 18 | /** |
| 19 | * Creates a new streaming input stream that reads from a parallel input stream. |
| 20 | * This adapter allows using a parallel input stream with APIs that expect a standard input stream. |
| 21 | * The adapter uses double-buffering to read ahead and provide efficient streaming. |
| 22 | * |
| 23 | * Note: The input stream only provides a blocking API to read, if reading from the same thread that |
| 24 | * will be used from `para_stream` to handle the parallel read, it's subjected to a dead lock!! |
| 25 | * Make sure the input stream is read from a different thread/thread pool that executes the `para_stream` reads. |
| 26 | * |
| 27 | * @param allocator The allocator to use for memory allocation |
| 28 | * @param para_stream The parallel input stream to read from |
| 29 | * @param buffer_ticket The buffer pool ticket to use for buffering |
| 30 | * @param offset The starting offset in the stream |
| 31 | * @param request_body_size The total size to read |
| 32 | * @param page_aligned Whether the input stream only read from the para_stream on that |
| 33 | * aligned with the page size, required for direct I/O in linux. |
| 34 | * @return A new input stream that reads from the parallel input stream |
| 35 | */ |
| 36 | AWS_S3_API |
| 37 | struct aws_input_stream *aws_part_streaming_input_stream_new( |
| 38 | struct aws_allocator *allocator, |
| 39 | struct aws_parallel_input_stream *para_stream, |
| 40 | struct aws_s3_buffer_ticket *buffer_ticket, |
| 41 | uint64_t offset, |
| 42 | size_t request_body_size, |
| 43 | bool page_aligned); |
| 44 | |
| 45 | AWS_EXTERN_C_END |
| 46 | AWS_POP_SANE_WARNING_LEVEL |
| 47 | |
| 48 | #endif /* AWS_S3_PART_STREAMING_INPUT_STREAM_H */ |