In our streams library we sometimes end up calling a wait() which can block/burn a thread. This goes against our principles. Here is one such example in streams.h around line 1131:
```
pplx::task<bool> operator()()
{
// We need to capture these, because the object itself may go away
// before we're done processing the data.
auto locs = _locals;
auto trg = _target;
auto after_putn = [=](size_t wr) mutable -> bool
{
locs->total += wr;
trg.sync().wait();
return true;
};
return _buffer.getn(locs->outbuf, buf_size).then(
[=] (size_t rd) mutable -> pplx::task<bool>
{
if ( rd == 0 ) return pplx::task_from_result(false);
return trg.putn(locs->outbuf, rd).then(after_putn);
});
}
```
Instead we should be hooking up the sync operation through a continuation and not blocking.
This was discovered by internal team.
When we fix this bug we should also double check that nowhere else other than in a task based continuation do we call 'get' or 'wait'.
```
pplx::task<bool> operator()()
{
// We need to capture these, because the object itself may go away
// before we're done processing the data.
auto locs = _locals;
auto trg = _target;
auto after_putn = [=](size_t wr) mutable -> bool
{
locs->total += wr;
trg.sync().wait();
return true;
};
return _buffer.getn(locs->outbuf, buf_size).then(
[=] (size_t rd) mutable -> pplx::task<bool>
{
if ( rd == 0 ) return pplx::task_from_result(false);
return trg.putn(locs->outbuf, rd).then(after_putn);
});
}
```
Instead we should be hooking up the sync operation through a continuation and not blocking.
This was discovered by internal team.
When we fix this bug we should also double check that nowhere else other than in a task based continuation do we call 'get' or 'wait'.