Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

Edited Issue: streams - a few places we block waiting on asynchronous operations to complete [135]

$
0
0
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'.


Viewing all articles
Browse latest Browse all 4845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>