QLocalSocket/Win: make emitReadyRead timer persistent
This saves us from creating a single shot timer every time we emit readyRead and eliminates the parallel pendingReadyRead flag. Done-with: ossi Change-Id: I1de7f07b83b583b9d60dd8862d6a9f7865b5b891 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
This commit is contained in:
parent
abccefa4a8
commit
3ccd626429
@ -134,7 +134,6 @@ private:
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_notified())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_canWrite())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_pipeClosed())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_emitReadyRead())
|
||||
#else
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_stateChanged(QAbstractSocket::SocketState))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_error(QAbstractSocket::SocketError))
|
||||
|
@ -134,7 +134,6 @@ public:
|
||||
void _q_notified();
|
||||
void _q_canWrite();
|
||||
void _q_pipeClosed();
|
||||
void _q_emitReadyRead();
|
||||
DWORD checkPipeState();
|
||||
void startAsyncRead();
|
||||
bool completeAsyncRead();
|
||||
@ -148,7 +147,7 @@ public:
|
||||
QWinEventNotifier *dataReadNotifier;
|
||||
QLocalSocket::LocalSocketError error;
|
||||
bool readSequenceStarted;
|
||||
bool pendingReadyRead;
|
||||
QTimer *emitReadyReadTimer;
|
||||
bool pipeClosed;
|
||||
static const qint64 initialReadBufferSize = 4096;
|
||||
#else
|
||||
|
@ -50,6 +50,9 @@ QT_BEGIN_NAMESPACE
|
||||
void QLocalSocketPrivate::init()
|
||||
{
|
||||
Q_Q(QLocalSocket);
|
||||
emitReadyReadTimer = new QTimer(q);
|
||||
emitReadyReadTimer->setSingleShot(true);
|
||||
QObject::connect(emitReadyReadTimer, SIGNAL(timeout()), q, SIGNAL(readyRead()));
|
||||
memset(&overlapped, 0, sizeof(overlapped));
|
||||
overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
dataReadNotifier = new QWinEventNotifier(overlapped.hEvent, q);
|
||||
@ -108,7 +111,7 @@ QLocalSocketPrivate::QLocalSocketPrivate() : QIODevicePrivate(),
|
||||
actualReadBufferSize(0),
|
||||
error(QLocalSocket::UnknownSocketError),
|
||||
readSequenceStarted(false),
|
||||
pendingReadyRead(false),
|
||||
emitReadyReadTimer(0),
|
||||
pipeClosed(false),
|
||||
state(QLocalSocket::UnconnectedState)
|
||||
{
|
||||
@ -236,13 +239,10 @@ qint64 QLocalSocket::readData(char *data, qint64 maxSize)
|
||||
void QLocalSocketPrivate::checkReadyRead()
|
||||
{
|
||||
if (actualReadBufferSize > 0) {
|
||||
if (!pendingReadyRead) {
|
||||
Q_Q(QLocalSocket);
|
||||
QTimer::singleShot(0, q, SLOT(_q_emitReadyRead()));
|
||||
pendingReadyRead = true;
|
||||
}
|
||||
if (!emitReadyReadTimer->isActive())
|
||||
emitReadyReadTimer->start();
|
||||
} else {
|
||||
pendingReadyRead = false;
|
||||
emitReadyReadTimer->stop();
|
||||
}
|
||||
}
|
||||
|
||||
@ -516,19 +516,10 @@ void QLocalSocketPrivate::_q_notified()
|
||||
return;
|
||||
}
|
||||
startAsyncRead();
|
||||
pendingReadyRead = false;
|
||||
emitReadyReadTimer->stop();
|
||||
emit q->readyRead();
|
||||
}
|
||||
|
||||
void QLocalSocketPrivate::_q_emitReadyRead()
|
||||
{
|
||||
if (pendingReadyRead) {
|
||||
Q_Q(QLocalSocket);
|
||||
pendingReadyRead = false;
|
||||
emit q->readyRead();
|
||||
}
|
||||
}
|
||||
|
||||
quintptr QLocalSocket::socketDescriptor() const
|
||||
{
|
||||
Q_D(const QLocalSocket);
|
||||
|
Loading…
Reference in New Issue
Block a user