Поддержка Redis

This commit is contained in:
2020-03-26 15:39:30 +03:00
parent d1613d814f
commit 8e70c4334b
16 changed files with 815 additions and 0 deletions

36
src/myx/redis/request.cpp Normal file
View File

@ -0,0 +1,36 @@
#include <QTimer>
#include <request.hpp>
#include <request_p.hpp>
using namespace qxredis;
void RequestPrivate::quitEventLoop()
{
loop.exit( 1 );
}
Request::Request( QObject* parent ) :
QObject( parent ),
d ( new RequestPrivate )
{
connect( this, &Request::reply, this, &Request::deleteLater );
}
bool Request::waitForReply( int msecs )
{
QTimer timer;
timer.setInterval( msecs );
timer.setSingleShot( true );
connect( &timer, &QTimer::timeout, &d->loop, &QEventLoop::quit );
connect( this, &Request::reply, d.data(), &RequestPrivate::quitEventLoop );
/*
* If the timer fires, the return value will be 0.
* Otherwise, quitEventLoop() will terminate the loop with 1.
*/
return( ( d->loop.exec( QEventLoop::ExcludeUserInputEvents ) != 0 ) );
}