bblanchon / ArduinoStreamUtils

💪 Power-ups for Arduino streams
MIT License
257 stars 21 forks source link

Always flush after... #14

Closed dpetican closed 3 years ago

dpetican commented 3 years ago

You do mention this as optional vis-a-vis the destructor calls flush. If the buffer is global and you send less than the buffer size and you want to see the ouptut right away then you have to flush. Is this correct?

bblanchon commented 3 years ago

Hi @dpetican,

Indeed, if the buffer is global, its destructor never runs, so you must call flush() explicitly.

Best Regards, Benoit

dpetican commented 3 years ago

I suggest to make this explicit in the documentation. Thanks.

bblanchon commented 3 years ago

Sure. How would you phrase it?

dpetican commented 3 years ago

After this sentance:

Calling flush() is recommended but not mandatory. If you don't call it, the destructor of WriteBufferingStream will do it for you.

When WriteBufferingStream is declared global, calling flush() is mandatory. However, you can keep adding to the buffer until you want the write to actually happen.

I didn't add: since there is no destructor for global variables. That would be pedantic.