[Development] [QIODevice]How to correctly treat/understand of the documentation?
Denis Shienkov
denis.shienkov at gmail.com
Sat Apr 19 08:42:27 CEST 2014
Hi Thiago,
many thanks for your answer..
== First issue ==
But still I didn't receive the concrete response: as to us to be? :)
In a buffer mode is to use the "deferred" writing or the "immediately"
writing?
This question causes many disputes in our QtSerialPort team ( even, up
to a fight :) ).
For example, I insist on "deferred", other members of team, e.g. on
"immediately".
Unfortunately, we can't come to a consensus in this question.
== Second issue ==
What about two scenarios ? (e.g. for some abstract I/O device):
1) Without flush():
MyClass::foo()
{
dev.write('a');
dev.write('b');
}
MyClass::bar()
{
dev.write('c');
dev.write('d');
}
when, the bar() method were called after foo() (with some delay), but
when not all data ("a" and "b") was written (e.g. was in time written
only "a").
then I expected to receive two: bytesWrittenSignal(2 byte) +
bytesWrittenSignal(2 byte)
2) With flush():
MyClass::foo()
{
dev.write('a');
dev.write('b');
}
MyClass::bar()
{
dev.write('c');
dev.write('d');
dev.flush();
}
when, the bar() method were called after foo() (with some delay), but
when not all data ("a" and "b") was written (e.g. was in time written
only "a").
then I expected to receive one bytesWrittenSignal(4 byte)
Whether correctly I understandаnd for expected behavior? Or, I'm wrong?
This question also causes many disputes since it is ambiguous.
BR,
Denis
18.04.2014 19:01, Thiago Macieira пишет:
> Em sex 18 abr 2014, às 18:14:43, Denis Shienkov escreveu:
>> Hi.
>>
>> I once again fluently look source codes of Qt and I see that the only one
>> I/O class which supports a buffered mode is QTcpSocket (i.e.
>> QAbstractSocket in buffered mode); in which is used the "deferred" writing
>> for data transfer.
>>
>> Thus, whether can I take such behavior (with "deferred" writing) as a basis
>> for implementation of I/O in QtSerialPort where only buffered mode is used
>> (as in QTcpSocket) ?
>>
>> Because I don't see other precedents and examples which to take as a basis.
> QProcess is also like that.
>
> In both cases, the underlying I/O mechanism cannot take unlimited amounts of
> data. The OS will only receive a certain number of bytes from the application
> before saying "no more". So the writeData() functions for those two classes
> must be able to buffer everything that can't be written immediately.
>
> Why it doesn't write immediately, I don't know. It was like that when I
> arrived in 2006.
>
More information about the Development
mailing list