@@ -953,41 +953,41 @@ namespace Concurrency { namespace streams
953
953
if ( !target.can_write () )
954
954
return pplx::task_from_exception<size_t >(std::make_exception_ptr (std::runtime_error (" source buffer not set up for input of data" )));
955
955
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>();
960
959
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 >
962
961
{
963
962
// We need to capture these, because the object itself may go away
964
963
// before we're done processing the data.
965
- auto locs = _locals;
966
- auto trg = target;
964
+ // auto locs = _locals;
965
+ // auto trg = target;
967
966
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 >
969
968
{
970
969
if (rd == 0 )
971
970
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 >
973
974
{
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 ; });
982
982
});
983
983
});
984
984
};
985
985
986
- auto loop = pplx::details::do_while (wrkarnd );
986
+ auto loop = pplx::details::do_while (copy_to_target );
987
987
988
988
return loop.then ([=](bool ) mutable -> size_t
989
989
{
990
- return _locals ->total ;
990
+ return l_locals ->total ;
991
991
});
992
992
}
993
993
0 commit comments