Skip to content

Commit 3445f61

Browse files
committed
Addressed final review comments
1 parent 2f44b84 commit 3445f61

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

Release/include/cpprest/streams.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -953,41 +953,41 @@ namespace Concurrency { namespace streams
953953
if ( !target.can_write() )
954954
return pplx::task_from_exception<size_t>(std::make_exception_ptr(std::runtime_error("source buffer not set up for input of data")));
955955

956-
// Capture 'buffer' rather than 'helper' here due to VC++ 2010 limitations.
957-
auto _buffer = helper()->m_buffer;
958-
auto bsz = this->buf_size;
959-
std::shared_ptr<_read_helper> _locals = std::make_shared<_read_helper>();
956+
auto l_buffer = helper()->m_buffer;
957+
auto l_buf_size = this->buf_size;
958+
std::shared_ptr<_read_helper> l_locals = std::make_shared<_read_helper>();
960959

961-
auto wrkarnd = [_locals, target, _buffer, bsz]() mutable -> pplx::task<bool>
960+
auto copy_to_target = [l_locals, target, l_buffer, l_buf_size]() mutable -> pplx::task<bool>
962961
{
963962
// We need to capture these, because the object itself may go away
964963
// before we're done processing the data.
965-
auto locs = _locals;
966-
auto trg = target;
964+
//auto locs = _locals;
965+
//auto trg = target;
967966

968-
return _buffer.getn(locs->outbuf, bsz).then([=](size_t rd) mutable -> pplx::task<bool>
967+
return l_buffer.getn(l_locals->outbuf, l_buf_size).then([=](size_t rd) mutable -> pplx::task<bool>
969968
{
970969
if (rd == 0)
971970
return pplx::task_from_result(false);
972-
return trg.putn(locs->outbuf, rd).then([=](size_t wr) mutable -> pplx::task<bool>
971+
972+
// Must be nested to capture rd
973+
return target.putn(l_locals->outbuf, rd).then([target, l_locals, rd](size_t wr) mutable -> pplx::task<bool>
973974
{
974-
locs->total += wr;
975-
return trg.sync().then([=]() -> bool
976-
{
977-
if (rd != wr)
978-
// Number of bytes written is less than number of bytes received.
979-
throw std::runtime_error("failed to write all bytes");
980-
return true;
981-
});
975+
l_locals->total += wr;
976+
977+
if (rd != wr)
978+
// Number of bytes written is less than number of bytes received.
979+
throw std::runtime_error("failed to write all bytes");
980+
981+
return target.sync().then([]() { return true; });
982982
});
983983
});
984984
};
985985

986-
auto loop = pplx::details::do_while(wrkarnd);
986+
auto loop = pplx::details::do_while(copy_to_target);
987987

988988
return loop.then([=](bool) mutable -> size_t
989989
{
990-
return _locals->total;
990+
return l_locals->total;
991991
});
992992
}
993993

0 commit comments

Comments
 (0)