[Development] [QIODevice]How to correctly treat/understand of the documentation?

Denis Shienkov denis.shienkov at gmail.com
Sun Apr 20 20:13:47 CEST 2014


Thiago,

many thanks for your time and answers.

Forgive for my importunity, but I shall ask also about following:

== 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 the foo(), when the Qt-event 
loop was entered after foo().
i.e. for example both foo() and bar() are the buttons-clicked-handlers.

then I expected to receive two: bytesWritten(2 byte) + bytesWritten(2 
byte) signals


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").
i.e. for example both foo() and bar() are the buttons-clicked-handlers, 
but the bar-button-clicked in the moment when not all data was written 
from the previous foo-button-clicked.

then I expected to receive one bytesWritten(4 byte) signal

3) With double flush():

MyClass::foo()
{
dev.write('a');
dev.write('b');
dev.flush();
}

MyClass::bar()
{
dev.write('c');
dev.write('d');
dev.flush();
}

what here I expect to receive after all data will be really transferred?

to receive two: bytesWritten(2 byte) + bytesWritten(2 byte) signals, or 
to receive one bytesWritten(4 byte) signal ?

====

Can you please comment it? What behaviour should be implemented for 
these three scenarios?

This question also causes many disputes since it is ambiguous. :(



BR,
Denis


19.04.2014 12:13, Thiago Macieira пишет:
> Em sáb 19 abr 2014, às 10:42:27, Denis Shienkov escreveu:
>> 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?
> You choose.
>
> If you choose to write immediately in writeData(), justify.
>
> Otherwise, follow existing practice. The following classes always buffer:
>   - QProcess
>   - QLocalSocket
>   - QAbstractSocket
>   - QSslSocket
>
> Similarly, none of the classes above and neither QNetworkReply actually read
> from the device in readData(). They only read from the buffer.
>
> I haven't looked at what QWebSocket does.




More information about the Development mailing list