binpac: Add FlowBuffer policy mechanisms

This allows for tunability of the following behaviors:

* Minimum flowbuffer capacity to use when parsing a new unit

* Threshold at which flowbuffer capacity is contracted back to the
  minimum after parsing a complete unit and before parsing the next

* Maximum flowbuffer capacity to allow when parsing a given unit

Failed flowbuffer allocations due to reaching maximum capacity or any
other reason now throw ExceptionFlowBufferAlloc.
This commit is contained in:
Jon Siwek 2019-04-05 12:21:42 -07:00 committed by Tim Wojtulewicz
parent 7e6e24a4d8
commit b4b229acf7
4 changed files with 73 additions and 13 deletions

View file

@ -116,6 +116,15 @@ public:
}
};
class ExceptionFlowBufferAlloc : public Exception
{
public:
ExceptionFlowBufferAlloc(const char* reason)
{
append(binpac_fmt("flowbuffer allocation failed: %s", reason));
}
};
}
#endif // binpac_exception_h