mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-18 23:41:08 +02:00
76 lines
1.1 KiB
C++
76 lines
1.1 KiB
C++
//
|
|
// AsyncClient.cpp
|
|
//
|
|
// $Id$
|
|
//
|
|
// Library: Redis
|
|
// Package: Redis
|
|
// Module: AsyncClient
|
|
//
|
|
// Implementation of the AsyncClient class.
|
|
//
|
|
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
|
// and Contributors.
|
|
//
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
//
|
|
|
|
#include "Poco/Redis/AsyncClient.h"
|
|
|
|
namespace Poco {
|
|
namespace Redis {
|
|
|
|
|
|
AsyncClient::AsyncClient() : Client(),
|
|
_activity(this, &AsyncClient::runActivity)
|
|
{
|
|
}
|
|
|
|
|
|
AsyncClient::AsyncClient(const std::string& hostAndPort) : Client(hostAndPort),
|
|
_activity(this, &AsyncClient::runActivity)
|
|
{
|
|
}
|
|
|
|
|
|
AsyncClient::AsyncClient(const std::string& host, int port) : Client(host, port),
|
|
_activity(this, &AsyncClient::runActivity)
|
|
{
|
|
}
|
|
|
|
|
|
AsyncClient::AsyncClient(const Net::SocketAddress& addrs) : Client(addrs),
|
|
_activity(this, &AsyncClient::runActivity)
|
|
{
|
|
}
|
|
|
|
|
|
AsyncClient::~AsyncClient()
|
|
{
|
|
stop();
|
|
}
|
|
|
|
|
|
void AsyncClient::runActivity()
|
|
{
|
|
while(!_activity.isStopped())
|
|
{
|
|
try
|
|
{
|
|
RedisType::Ptr reply = readReply();
|
|
redisResponse.notify(this, reply);
|
|
}
|
|
catch(TimeoutException&)
|
|
{
|
|
continue;
|
|
}
|
|
catch(Exception &)
|
|
{
|
|
stop();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
} } // Poco::Redis
|