Skip to content

Commit a6bdc11

Browse files
committed
Async: Rename AsyncPipeline::Sink to AsyncPipeline::Pipe
1 parent a075702 commit a6bdc11

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

Libraries/Async/AsyncStreams.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,9 @@ SC::Result SC::AsyncPipeline::start()
469469
SC_TRY_MSG(source != nullptr, "AsyncPipeline::start - Missing source");
470470

471471
AsyncBuffersPool& buffers = source->getBuffersPool();
472-
for (Sink sink : sinks)
472+
for (const Pipe& pipe : pipes)
473473
{
474-
if (&sink.sink->getBuffersPool() != &buffers)
474+
if (&pipe.sink->getBuffersPool() != &buffers)
475475
{
476476
return Result::Error("AsyncPipeline::start - all streams must use the same AsyncBuffersPool");
477477
}
@@ -484,12 +484,12 @@ SC::Result SC::AsyncPipeline::start()
484484

485485
void SC::AsyncPipeline::onBufferRead(AsyncBufferView::ID bufferID)
486486
{
487-
for (Sink sink : sinks)
487+
for (const Pipe& pipe : pipes)
488488
{
489489
source->getBuffersPool().refBuffer(bufferID); // 4a. AsyncPipeline::onBufferWritten
490490
Function<void(AsyncBufferView::ID)> cb;
491491
cb.bind<AsyncPipeline, &AsyncPipeline::onBufferWritten>(*this);
492-
Result res = sink.sink->write(bufferID, move(cb));
492+
Result res = pipe.sink->write(bufferID, move(cb));
493493
if (not res)
494494
{
495495
eventError.emit(res);

Libraries/Async/AsyncStreams.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,17 +240,18 @@ struct AsyncWritableStream
240240
/// @note It's crucial to use the same AsyncBuffersPool for the AsyncReadableStream and all AsyncWritableStream
241241
struct AsyncPipeline
242242
{
243-
static constexpr int MaxListeners = 8;
243+
static constexpr int MaxListeners = 8;
244+
244245
Event<MaxListeners, Result> eventError; /// Emitted when an error occurs
245246

246247
// TODO: Make all these private
247248
AsyncReadableStream* source = nullptr; /// User specified source
248249

249-
struct Sink
250+
struct Pipe
250251
{
251252
AsyncWritableStream* sink = nullptr;
252253
};
253-
Span<Sink> sinks; /// User specified sinks
254+
Span<Pipe> pipes; /// User specified sinks
254255

255256
/// @brief Starts the pipeline
256257
/// @note Both source and sinks must have been already setup by the caller

Libraries/Async/Tests/AsyncRequestStreamsTest.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ void SC::AsyncRequestStreamsTest::fileToFile()
145145
// Create Pipeline
146146
AsyncPipeline pipeline;
147147

148-
AsyncPipeline::Sink destinations[1];
149-
pipeline.source = &readable;
150-
pipeline.sinks = {destinations, 1};
151-
destinations[0].sink = &writable;
148+
AsyncPipeline::Pipe pipe[1];
149+
pipeline.source = &readable;
150+
pipeline.pipes = {pipe, 1};
151+
pipe[0].sink = &writable;
152152

153153
SC_TEST_EXPECT(pipeline.start());
154154

@@ -297,19 +297,19 @@ void SC::AsyncRequestStreamsTest::fileToSocketToFile()
297297
// Create Pipelines
298298
AsyncPipeline pipelines[2];
299299

300-
AsyncPipeline::Sink sinks[2];
300+
AsyncPipeline::Pipe pipes[2];
301301

302302
// Create first Async Pipeline (file to socket)
303303
pipelines[0].source = &readFileStream;
304-
pipelines[0].sinks = {&sinks[0], 1};
304+
pipelines[0].pipes = {&pipes[0], 1};
305305

306-
pipelines[0].sinks[0].sink = &writeSocketStream;
306+
pipelines[0].pipes[0].sink = &writeSocketStream;
307307

308308
// Create second Async Pipeline (socket to file)
309309
pipelines[1].source = &readSocketStream;
310-
pipelines[1].sinks = {&sinks[1], 1};
310+
pipelines[1].pipes = {&pipes[1], 1};
311311

312-
pipelines[1].sinks[0].sink = &writeFileStream;
312+
pipelines[1].pipes[0].sink = &writeFileStream;
313313

314314
// Start Async Pipeline
315315
SC_TEST_EXPECT(pipelines[0].start());

0 commit comments

Comments
 (0)