diff --git a/targets.cc b/targets.cc index 1dd199046..b0fdacaf2 100644 --- a/targets.cc +++ b/targets.cc @@ -401,9 +401,10 @@ HostGroupState::~HostGroupState() { free(hostbatch); } +/* Returns true iff the defer buffer is not yet full. */ bool HostGroupState::defer(Target *t) { this->defer_buffer.push_back(t); - return true; + return this->defer_buffer.size() < HostGroupState::DEFER_LIMIT; } void HostGroupState::undefer() { diff --git a/targets.h b/targets.h index d65700fd6..97992a00c 100644 --- a/targets.h +++ b/targets.h @@ -157,6 +157,9 @@ public: class HostGroupState { public: + /* The maximum number of entries we want to allow storing in defer_buffer. */ + static const unsigned int DEFER_LIMIT = 64; + HostGroupState(int lookahead, int randomize, int argc, const char *argv[]); ~HostGroupState(); Target **hostbatch; @@ -180,6 +183,7 @@ public: at a time to the client program */ TargetGroup current_group; /* For batch chunking -- targets in queue */ + /* Returns true iff the defer buffer is not yet full. */ bool defer(Target *t); void undefer(); const char *next_expression();