Files
poco/Redis/src/AsyncReader.cpp
2015-11-07 21:46:11 +01:00

61 lines
927 B
C++

//
// AsyncReader.cpp
//
// $Id$
//
// Library: Redis
// Package: Redis
// Module: AsyncReader
//
// Implementation of the AsyncReader class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Redis/AsyncReader.h"
namespace Poco {
namespace Redis {
AsyncReader::AsyncReader(Client& client) : _client(client),
_activity(this, &AsyncReader::runActivity)
{
}
AsyncReader::~AsyncReader()
{
stop();
}
void AsyncReader::runActivity()
{
while(!_activity.isStopped())
{
try
{
RedisType::Ptr reply = _client.readReply();
RedisEventArgs args(reply);
redisResponse.notify(this, args);
if ( args.isStopped() ) stop();
}
catch(Exception& e)
{
RedisEventArgs args(&e);
redisException.notify(this, args);
stop();
}
if (!_activity.isStopped()) Thread::trySleep(100);
}
}
} } // Poco::Redis