Commit 708b3d77 authored by Alexey Spiridonov's avatar Alexey Spiridonov Committed by Dave Watson

Small readability improvements

Summary: I got confused by the error message, and wasn't quite clear on the intent of communicateIOBuf()

Test Plan: waiting for auto-unittests
@override-unit-failures

Reviewed By: tudorb@fb.com

FB internal diff: D1297525
parent 934b3c4f
...@@ -58,8 +58,9 @@ ProcessReturnCode::State ProcessReturnCode::state() const { ...@@ -58,8 +58,9 @@ ProcessReturnCode::State ProcessReturnCode::state() const {
void ProcessReturnCode::enforce(State expected) const { void ProcessReturnCode::enforce(State expected) const {
State s = state(); State s = state();
if (s != expected) { if (s != expected) {
throw std::logic_error(to<std::string>("Invalid state ", s, throw std::logic_error(to<std::string>(
" expected ", expected)); "Bad use of ProcessReturnCode; state is ", s, " expected ", expected
));
} }
} }
......
...@@ -341,12 +341,15 @@ class Subprocess : private boost::noncopyable { ...@@ -341,12 +341,15 @@ class Subprocess : private boost::noncopyable {
* If stdout or stderr is not a pipe, an empty IOBuf queue will be returned * If stdout or stderr is not a pipe, an empty IOBuf queue will be returned
* for the respective buffer. * for the respective buffer.
* *
* Note that communicate() returns when all pipes to/from the child are * Note that communicate() and communicateIOBuf() both return when all
* closed; the child might stay alive after that, so you must still wait(). * pipes to/from the child are closed; the child might stay alive after
* that, so you must still wait().
*
* communicateIOBuf() uses IOBufQueue for buffering (which has the
* advantage that it won't try to allocate all data at once), but it does
* store the subprocess's entire output in memory before returning.
* *
* communicateIOBuf uses IOBufQueue for buffering (which has the advantage * communicate() uses strings for simplicity.
* that it won't try to allocate all data at once). communicate
* uses strings for simplicity.
*/ */
std::pair<IOBufQueue, IOBufQueue> communicateIOBuf( std::pair<IOBufQueue, IOBufQueue> communicateIOBuf(
IOBufQueue input = IOBufQueue()); IOBufQueue input = IOBufQueue());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment