From 708b3d777e39d715cf3b1f0e688e95b9bf9fa166 Mon Sep 17 00:00:00 2001 From: Alexey Spiridonov Date: Fri, 25 Apr 2014 15:38:38 -0700 Subject: [PATCH] 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 --- folly/Subprocess.cpp | 5 +++-- folly/Subprocess.h | 13 ++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/folly/Subprocess.cpp b/folly/Subprocess.cpp index 10740944..9c2b32d0 100644 --- a/folly/Subprocess.cpp +++ b/folly/Subprocess.cpp @@ -58,8 +58,9 @@ ProcessReturnCode::State ProcessReturnCode::state() const { void ProcessReturnCode::enforce(State expected) const { State s = state(); if (s != expected) { - throw std::logic_error(to("Invalid state ", s, - " expected ", expected)); + throw std::logic_error(to( + "Bad use of ProcessReturnCode; state is ", s, " expected ", expected + )); } } diff --git a/folly/Subprocess.h b/folly/Subprocess.h index f189bb49..8af7c639 100644 --- a/folly/Subprocess.h +++ b/folly/Subprocess.h @@ -341,12 +341,15 @@ class Subprocess : private boost::noncopyable { * If stdout or stderr is not a pipe, an empty IOBuf queue will be returned * for the respective buffer. * - * Note that communicate() returns when all pipes to/from the child are - * closed; the child might stay alive after that, so you must still wait(). + * Note that communicate() and communicateIOBuf() both return when all + * 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 - * that it won't try to allocate all data at once). communicate - * uses strings for simplicity. + * communicate() uses strings for simplicity. */ std::pair communicateIOBuf( IOBufQueue input = IOBufQueue()); -- 2.34.1