Skip to content

Commit e4a9840

Browse files
author
Valtteri Heikkila
committed
Merge remote-tracking branch 'upstream/development' into development
2 parents 465f5e4 + 79b217a commit e4a9840

File tree

4 files changed

+67
-35
lines changed

4 files changed

+67
-35
lines changed

Release/include/cpprest/astreambuf.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,9 @@ namespace Concurrency { namespace streams
969969
/// <param name="mode">The I/O mode (in or out) to close for.</param>
970970
virtual pplx::task<void> close(std::ios_base::openmode mode = (std::ios_base::in | std::ios_base::out))
971971
{
972-
return get_base()->close(mode);
972+
// We preserve the check here to workaround a Dev10 compiler crash
973+
auto buffer = get_base();
974+
return buffer ? buffer->close(mode) : pplx::task_from_result();
973975
}
974976

975977
/// <summary>
@@ -979,7 +981,9 @@ namespace Concurrency { namespace streams
979981
/// <param name="eptr">Pointer to the exception.</param>
980982
virtual pplx::task<void> close(std::ios_base::openmode mode, std::exception_ptr eptr)
981983
{
982-
return get_base()->close(mode, eptr);
984+
// We preserve the check here to workaround a Dev10 compiler crash
985+
auto buffer = get_base();
986+
return buffer ? buffer->close(mode, eptr) : pplx::task_from_result();
983987
}
984988

985989
/// <summary>

Release/include/cpprest/asyncrt_utils.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,6 @@ namespace conversions
148148
/// </summary>
149149
_ASYNCRTIMP std::vector<unsigned char> __cdecl from_base64(const utility::string_t& str);
150150

151-
/// <summary>
152-
/// Converts a type that supports the stream operator << to a string.
153-
/// </summary>
154-
/// <param name="val">Value to convert to a string.</param>
155-
/// <returns>String representation of the value</returns>
156151
template <typename Source>
157152
utility::string_t print_string(const Source &val)
158153
{
@@ -162,12 +157,6 @@ namespace conversions
162157
throw std::bad_cast();
163158
return oss.str();
164159
}
165-
166-
/// <summary>
167-
/// Creates a type from a string using the stream operator >>.
168-
/// </summary>
169-
/// <param name="str">String to create type from.</param>
170-
/// <returns>An instance of type Target.</returns>
171160
template <typename Target>
172161
Target scan_string(const utility::string_t &str)
173162
{

Release/include/cpprest/filestream.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,12 @@ namespace details {
222222
return pplx::create_task(result_tce);
223223
}
224224

225-
pplx::task<void> _close_read()
225+
// Use a separated function for working around Dev10's ICE
226+
pplx::task<void> _close_read_impl()
226227
{
227-
return m_readOps.enqueue_operation([this]()
228-
{
229228
streambuf_state_manager<_CharType>::_close_read();
230229

231-
if (this->can_write())
230+
if (this->can_write())
232231
{
233232
return pplx::task_from_result();
234233
}
@@ -240,7 +239,11 @@ namespace details {
240239

241240
return _close_file(fileInfo);
242241
}
243-
});
242+
}
243+
244+
pplx::task<void> _close_read()
245+
{
246+
return m_readOps.enqueue_operation([this] { return _close_read_impl(); });
244247
}
245248

246249
pplx::task<void> _close_write()

Release/include/cpprest/streams.h

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

954+
// Capture 'buffer' rather than 'helper' here due to VC++ 2010 limitations.
955+
auto buffer = helper()->m_buffer;
956+
954957
std::shared_ptr<_read_helper> _locals = std::make_shared<_read_helper>();
955-
return pplx::details::do_while([=]() mutable
956-
{
957-
return helper()->m_buffer.getn(_locals->outbuf, buf_size).then([=](size_t rd) mutable
958-
{
959-
if (rd == 0) return pplx::task_from_result(false);
960-
return target.putn(_locals->outbuf, rd).then([=](size_t wr) mutable
961-
{
962-
_locals->total += wr;
963-
return target.sync();
964-
}).then([]()
965-
{
966-
return true;
967-
});
958+
959+
_dev10_ice_workaround wrkarnd(buffer, target, _locals, buf_size);
960+
961+
auto loop = pplx::details::do_while(wrkarnd);
962+
963+
return loop.then([=](bool) mutable -> size_t
964+
{
965+
return _locals->total;
968966
});
969-
}).then([=](bool) mutable -> size_t
970-
{
971-
return _locals->total;
972-
});
973967
}
974968

975969
/// <summary>
@@ -1107,6 +1101,48 @@ namespace Concurrency { namespace streams
11071101
{
11081102
}
11091103
};
1104+
1105+
// To workaround a VS 2010 internal compiler error, we have to do our own
1106+
// "lambda" here...
1107+
class _dev10_ice_workaround
1108+
{
1109+
public:
1110+
_dev10_ice_workaround(streams::streambuf<CharType> buffer,
1111+
concurrency::streams::streambuf<CharType> target,
1112+
std::shared_ptr<typename basic_istream::_read_helper> locals,
1113+
size_t buf_size)
1114+
: _buffer(buffer), _target(target), _locals(locals), _buf_size(buf_size)
1115+
{
1116+
}
1117+
pplx::task<bool> operator()()
1118+
{
1119+
// We need to capture these, because the object itself may go away
1120+
// before we're done processing the data.
1121+
auto locs = _locals;
1122+
auto trg = _target;
1123+
1124+
auto after_putn =
1125+
[=](size_t wr) mutable -> bool
1126+
{
1127+
locs->total += wr;
1128+
trg.sync().wait();
1129+
return true;
1130+
};
1131+
1132+
return _buffer.getn(locs->outbuf, buf_size).then(
1133+
[=] (size_t rd) mutable -> pplx::task<bool>
1134+
{
1135+
if ( rd == 0 )
1136+
return pplx::task_from_result(false);
1137+
return trg.putn(locs->outbuf, rd).then(after_putn);
1138+
});
1139+
}
1140+
private:
1141+
size_t _buf_size;
1142+
concurrency::streams::streambuf<CharType> _buffer;
1143+
concurrency::streams::streambuf<CharType> _target;
1144+
std::shared_ptr<typename basic_istream::_read_helper> _locals;
1145+
};
11101146

11111147
std::shared_ptr<details::basic_istream_helper<CharType>> m_helper;
11121148
};

0 commit comments

Comments
 (0)