Renamed AsyncClient into AsyncReader

This commit is contained in:
fbraem
2015-11-02 22:08:27 +01:00
parent 93a2cced8d
commit cb8b6cfe8d
5 changed files with 150 additions and 174 deletions

View File

@@ -1,98 +0,0 @@
//
// AsyncClient.h
//
// $Id$
//
// Library: Redis
// Package: Redis
// Module: AsyncClient
//
// Definition of the AsyncClient class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef Redis_AsyncClient_INCLUDED
#define Redis_AsyncClient_INCLUDED
#include "Poco/Redis/Redis.h"
#include "Poco/Redis/Client.h"
#include "Poco/Activity.h"
namespace Poco {
namespace Redis {
class Redis_API AsyncClient : public Client
{
public:
BasicEvent<RedisType::Ptr> redisResponse;
AsyncClient();
/// Default constructor. Use this when you want to
/// connect later on.
AsyncClient(const std::string& hostAndPort);
/// Constructor which connects to the given Redis host/port.
/// The host and port must be separated with a colon.
AsyncClient(const std::string& host, int port);
/// Constructor which connects to the given Redis host/port.
AsyncClient(const Net::SocketAddress& addrs);
/// Constructor which connects to the given Redis host/port.
virtual ~AsyncClient();
/// Destructor
bool isStopped();
/// Returns true if the activity is not running, false when it is.
void start();
/// Starts the activity to read replies from the Redis server.
void stop();
/// Stops the read activity.
protected:
void runActivity();
private:
AsyncClient(const AsyncClient&);
AsyncClient& operator = (const AsyncClient&);
Activity<AsyncClient> _activity;
};
inline bool AsyncClient::isStopped()
{
return _activity.isStopped();
}
inline void AsyncClient::start()
{
_activity.start();
}
inline void AsyncClient::stop()
{
_activity.stop();
}
} } // namespace Poco::Redis
#endif //Redis_Client_INCLUDED

View File

@@ -0,0 +1,92 @@
//
// AsyncReader.h
//
// $Id$
//
// Library: Redis
// Package: Redis
// Module: AsyncReader
//
// Definition of the AsyncReader class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef Redis_AsyncReader_INCLUDED
#define Redis_AsyncReader_INCLUDED
#include "Poco/Redis/Redis.h"
#include "Poco/Redis/Client.h"
#include "Poco/Activity.h"
namespace Poco {
namespace Redis {
class Redis_API AsyncReader
/// Wrapper around a Redis client to read messages asynchronously. Use this
/// for publish/subscribe. The redisResponse event is used to notify that
/// a message is received. When a reader is started for a Redis server,
/// you should use execute<void>, because this class is responsible for
/// reading all replies.
{
public:
BasicEvent<RedisType::Ptr> redisResponse;
/// Event that is called when a message is received
AsyncReader(Client& client);
/// Constructor.
virtual ~AsyncReader();
/// Destructor
bool isStopped();
/// Returns true if the activity is not running, false when it is.
void start();
/// Starts the activity to read replies from the Redis server.
void stop();
/// Stops the read activity.
protected:
void runActivity();
private:
AsyncReader(const AsyncReader&);
AsyncReader& operator = (const AsyncReader&);
Activity<AsyncReader> _activity;
Client& _client;
};
inline bool AsyncReader::isStopped()
{
return _activity.isStopped();
}
inline void AsyncReader::start()
{
_activity.start();
}
inline void AsyncReader::stop()
{
_activity.stop();
}
} } // namespace Poco::Redis
#endif //Redis_AsyncReader_INCLUDED