mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-02-23 13:17:14 +01:00
Switched to POCO library for unified platform/library interface. Deprecated the external module API. It was creating more problems than solving. Removed most built-in libraries in favor of system libraries for easier maintenance. Cleaned and secured code with help from static analyzers.
62 lines
931 B
C++
62 lines
931 B
C++
//
|
|
// AsyncReader.cpp
|
|
//
|
|
// Library: Redis
|
|
// Package: Redis
|
|
// Module: AsyncReader
|
|
//
|
|
// Implementation of the AsyncReader class.
|
|
//
|
|
// Copyright (c) 2015, 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);
|
|
}
|
|
}
|
|
|
|
|
|
} } // namespace Poco::Redis
|