#pragma once
#include "RedisSubscriber_global.h"
#include "Publisher.h"
#include "RedisClient.h"
#include <QQueue>
#include <QMutex>
#include <QWaitCondition>
struct Msg{
    QString key;
    QString val;
};
class REDISSUBSCRIBER_EXPORT RedisSubscriber : public Publisher
{
    Q_OBJECT
public:
    RedisSubscriber();
    // virtual void shares(SharedData * share);
    virtual void Run(const ModuleInfo& mi);
    virtual void setLoader(QLibrary*);
    void enqueue(const QString& key,const QString& val);
protected:
    virtual void run();
signals:
    void pubData(const QString& ,const QString& ,const QVariant&);
private:
    RedisClient* redis;
    QMutex mutex;
    QWaitCondition cond;
    QQueue<Msg> msgQueue;
};


extern "C" {//一定要添加上
REDISSUBSCRIBER_EXPORT Publisher* instance();
REDISSUBSCRIBER_EXPORT void destroy(Publisher*);
}
