[fpc-devel] ConsoleIO and flushing buffered output
Christo Crause
christo.crause at gmail.com
Tue Jun 9 18:38:55 CEST 2020
On Tue, Jun 9, 2020 at 10:55 AM Tomas Hajny <XHajT03 at hajny.biz> wrote:
> Note that there is an (intended) difference between output to console
> and output to files (Do_IsDevice provides this differentiation in
> standard RTL). Output to console is supposed to be flushed after every
> Write(Ln) statement, because it should provide immediate feedback to the
> user.
This already works well enough, the normal use case doesn't require a low
level flush.
> [...]
>
> Finally, note that TP-compatible part of the standard RTL does _not_
> call the ("low-level") flush call of the underlying operating system.
> Such calls exist in API for most platforms (DOS: int 21h, AH=68h; OS/2:
> DosResetBuffer; Unix: (fp)fsync; WinXX: FlushFileBuffers), but they are
> not used within our RTL implementation as far as I know (flushing is
> always performed automatically when closing a file, but the operating
> systems take care of that).
>
Indeed, the functionality implemented in the RTL is about managing the RTL
buffers and leaving the downstream work in the hands of the OS (or whatever
custom function is hooked to InOutFunc). I cannot see a simple way to
re-use one of the fields in TextRec to provide what would amount to new
functionality, this leaves the option of adding another field to TextRec
for a low level flush. This is however not moving in the appropriate
direction, since this would lead to higher memory consumption on lower end
targets. Perhaps a separate platform specific low level flush is the best
compromise for the few use cases requiring low level control.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20200609/a6ccd6a6/attachment.htm>
More information about the fpc-devel
mailing list