[fpc-devel] StdOut capture for FPC RTL
Anton Kavalenka
anton.k at tut.by
Thu Nov 25 11:16:12 CET 2010
?? 25.11.2010 12:01, Jonas Maebe ???????(??):
>
> On 25 Nov 2010, at 10:52, Anton Kavalenka wrote:
>
>> Due to incompatibility of RTL between FPC and Delphi my capturing
>> tricks not work.
>> BTW what the real reason to make these files as threadvar?
>
> To prevent multiple threads writing to stdin/stdout/sterr at the same
> time from corrupting each other's data (all of these text files use an
> internal buffer, even when the output is immediately flushed afterwards).
>
>
> Jonas
>
>
> _______________________________________________
> fpc-devel maillist - fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel
Is not the better way to use something like this:
lock_output();
try
// do something nasty with the buffer
finally
flush(output);
unlock_output();
end;
There is NO other runtimes on this planet instead FPC RTL which take
care of per-thread buffer of output.
It is programmers duty to lock/flush buffer in multithreaded environments.
If FPC wants to be so nice - let's introduce critical section in output
structure.
Any outputs would be suspended until a thread acquires it by write
operation.
regards,
Anton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20101125/2aa04028/attachment.html>
More information about the fpc-devel
mailing list