Skip to content

Commit e0d42b5

Browse files
garethsbras0219-msft
authored andcommitted
Fix compilation failure with CPPREST_FORCE_PPLX=1 (resolves #734) (#746)
* Make sure internal _do_while is in the same namespace as other pplx tasks implementation details (resolves #734) * Reformat astreambuf.h line endings
1 parent b024470 commit e0d42b5

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

Release/include/cpprest/astreambuf.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
#include "cpprest/details/basic_types.h"
2323
#include "cpprest/asyncrt_utils.h"
2424

25-
namespace Concurrency
25+
#if (defined(_MSC_VER) && (_MSC_VER >= 1800)) && !CPPREST_FORCE_PPLX
26+
namespace Concurrency // since namespace pplx = Concurrency
27+
#else
28+
namespace pplx
29+
#endif
2630
{
2731
namespace details
2832
{
@@ -32,12 +36,16 @@ namespace Concurrency
3236
pplx::task<T> first = func();
3337
return first.then([=](bool guard) -> pplx::task<T> {
3438
if (guard)
35-
return Concurrency::details::_do_while<F,T>(func);
39+
return pplx::details::_do_while<F,T>(func);
3640
else
3741
return first;
3842
});
3943
}
4044
}
45+
}
46+
47+
namespace Concurrency
48+
{
4149

4250
/// Library for asynchronous streams.
4351
namespace streams
@@ -1201,4 +1209,4 @@ namespace streams
12011209

12021210
}}
12031211

1204-
1212+

Release/include/cpprest/streams.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ namespace Concurrency { namespace streams
801801
return true;
802802
};
803803

804-
auto loop = Concurrency::details::_do_while([=]() mutable -> pplx::task<bool>
804+
auto loop = pplx::details::_do_while([=]() mutable -> pplx::task<bool>
805805
{
806806
while (buffer.in_avail() > 0)
807807
{
@@ -888,7 +888,7 @@ namespace Concurrency { namespace streams
888888
return pplx::task_from_result(false);
889889
};
890890

891-
auto loop = Concurrency::details::_do_while([=]() mutable -> pplx::task<bool>
891+
auto loop = pplx::details::_do_while([=]() mutable -> pplx::task<bool>
892892
{
893893
while ( buffer.in_avail() > 0 )
894894
{
@@ -968,7 +968,7 @@ namespace Concurrency { namespace streams
968968
});
969969
};
970970

971-
auto loop = Concurrency::details::_do_while(copy_to_target);
971+
auto loop = pplx::details::_do_while(copy_to_target);
972972

973973
return loop.then([=](bool) mutable -> size_t
974974
{
@@ -1142,7 +1142,7 @@ pplx::task<void> _type_parser_base<CharType>::_skip_whitespace(streams::streambu
11421142
return false;
11431143
};
11441144

1145-
auto loop = Concurrency::details::_do_while([=]() mutable -> pplx::task<bool>
1145+
auto loop = pplx::details::_do_while([=]() mutable -> pplx::task<bool>
11461146
{
11471147
while (buffer.in_avail() > 0)
11481148
{
@@ -1217,7 +1217,7 @@ pplx::task<ReturnType> _type_parser_base<CharType>::_parse_input(
12171217
return _skip_whitespace(buffer).then([=](pplx::task<void> op) -> pplx::task<ReturnType>
12181218
{
12191219
op.wait();
1220-
return Concurrency::details::_do_while(peek_char).then(finish);
1220+
return pplx::details::_do_while(peek_char).then(finish);
12211221
});
12221222
}
12231223

Release/tests/functional/streams/istream_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ TEST(fstream_read_to_end_3)
714714
else
715715
return pplx::task_from_result(false);
716716
};
717-
Concurrency::details::_do_while([=]()-> pplx::task<bool> {
717+
pplx::details::_do_while([=]()-> pplx::task<bool> {
718718
return stream.read().then(lambda1);
719719
}).wait();
720720

Release/tests/functional/streams/memstream_tests.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void streambuf_putc(StreamBufferType& wbuf)
4848
size_t count = 10;
4949
auto seg2 = [&count](typename StreamBufferType::int_type ) { return (--count > 0); };
5050
auto seg1 = [&s,&wbuf, seg2]() { return wbuf.putc(s[0]).then(seg2); };
51-
Concurrency::details::_do_while(seg1).wait();
51+
pplx::details::_do_while(seg1).wait();
5252

5353
VERIFY_ARE_EQUAL(s.size() + 10, wbuf.in_avail());
5454

@@ -83,7 +83,7 @@ void streambuf_putc(concurrency::streams::rawptr_buffer<CharType>& wbuf)
8383
size_t count = 10;
8484
auto seg2 = [&count](typename StreamBufferType::int_type ) { return (--count > 0); };
8585
auto seg1 = [&s,&wbuf, seg2]() { return wbuf.putc(s[0]).then(seg2); };
86-
Concurrency::details::_do_while(seg1).wait();
86+
pplx::details::_do_while(seg1).wait();
8787

8888
VERIFY_ARE_EQUAL(s.size() + 10, wbuf.block().size());
8989

@@ -119,7 +119,7 @@ void streambuf_putc(concurrency::streams::container_buffer<CollectionType>& wbuf
119119
size_t count = 10;
120120
auto seg2 = [&count](typename StreamBufferType::int_type ) { return (--count > 0); };
121121
auto seg1 = [&s,&wbuf, seg2]() { return wbuf.putc(s[0]).then(seg2); };
122-
Concurrency::details::_do_while(seg1).wait();
122+
pplx::details::_do_while(seg1).wait();
123123

124124
VERIFY_ARE_EQUAL(s.size() + 10, wbuf.collection().size());
125125

@@ -150,7 +150,7 @@ void streambuf_putn(StreamBufferType& wbuf)
150150
int count = 10;
151151
auto seg2 = [&count](size_t ) { return (--count > 0); };
152152
auto seg1 = [&s,&wbuf, seg2]() { return wbuf.putn_nocopy(s.data(), s.size()).then(seg2); };
153-
Concurrency::details::_do_while(seg1).wait();
153+
pplx::details::_do_while(seg1).wait();
154154
VERIFY_ARE_EQUAL(s.size() * 12, wbuf.in_avail());
155155

156156
wbuf.close().get();
@@ -180,7 +180,7 @@ void streambuf_putn(concurrency::streams::rawptr_buffer<CharType>& wbuf)
180180
int count = 10;
181181
auto seg2 = [&count](size_t ) { return (--count > 0); };
182182
auto seg1 = [&s,&wbuf, seg2]() { return wbuf.putn_nocopy(s.data(), s.size()).then(seg2); };
183-
Concurrency::details::_do_while(seg1).wait();
183+
pplx::details::_do_while(seg1).wait();
184184

185185
wbuf.close().get();
186186
VERIFY_IS_FALSE(wbuf.can_write());
@@ -209,7 +209,7 @@ void streambuf_putn(concurrency::streams::container_buffer<CollectionType>& wbuf
209209
int count = 10;
210210
auto seg2 = [&count](size_t ) { return (--count > 0); };
211211
auto seg1 = [&s,&wbuf, seg2]() { return wbuf.putn_nocopy(s.data(), s.size()).then(seg2); };
212-
Concurrency::details::_do_while(seg1).wait();
212+
pplx::details::_do_while(seg1).wait();
213213

214214
wbuf.close().get();
215215
VERIFY_IS_FALSE(wbuf.can_write());
@@ -1935,7 +1935,7 @@ void IStreamTest11()
19351935
auto seg2 = [&ch](int val) { return (val != -1) && (++ch <= 'z'); };
19361936
auto seg1 = [=,&ch,&rbuf]() { return rbuf.putc(ch).then(seg2); };
19371937

1938-
Concurrency::details::_do_while(seg1).wait();
1938+
pplx::details::_do_while(seg1).wait();
19391939

19401940
VERIFY_ARE_EQUAL(26u, rbuf.in_avail());
19411941

0 commit comments

Comments
 (0)