提交 745bd500 编写于 作者: 丁劲犇's avatar 丁劲犇 😸

PREPARE TO JOIN

上级 3a8660d0
#include "zp_clusterterm.h"
namespace ZP_Cluster{
zp_ClusterTerm::zp_ClusterTerm(const QString & name,int nTransThreads ,int nWorkingThreads,QObject *parent ) :
QObject(parent)
,m_strTermName(name)
{
m_pClusterEng = new ZPTaskEngine::zp_pipeline(this);
m_pClusterEng->addThreads(nWorkingThreads);
m_pClusterNet = new ZPNetwork::zp_net_ThreadPool(8192,this);
m_pClusterNet->AddClientTransThreads(nTransThreads);
zp_ClusterTerm::zp_ClusterTerm(const QString & name,QObject *parent ) :
QObject(parent)
,m_strTermName(name)
{
m_pClusterEng = new ZPTaskEngine::zp_pipeline(this);
m_pClusterNet = new ZPNetwork::zp_net_ThreadPool(8192,this);
}
void zp_ClusterTerm::StartListen(const QHostAddress &addr, int nPort)
{
m_pClusterNet->AddListeningAddress(m_strTermName,addr,nPort,false);
}
void zp_ClusterTerm::StartListen(const QHostAddress &addr, int nPort)
{
m_pClusterNet->AddListeningAddress(m_strTermName,addr,nPort,false);
}
bool zp_ClusterTerm::JoinCluster(const QHostAddress &addr, int nPort)
{
return m_pClusterNet->connectTo(addr,nPort);
}
bool zp_ClusterTerm::canExit()
{
return m_pClusterEng->canClose() && m_pClusterNet->CanExit();
}
}
bool zp_ClusterTerm::JoinCluster(const QHostAddress &addr, int nPort)
{
return m_pClusterNet->connectTo(addr,nPort);
}
bool zp_ClusterTerm::canExit()
{
return m_pClusterEng->canClose() && m_pClusterNet->CanExit();
}
}
......@@ -8,31 +8,31 @@
#include "../pipeline/zp_pltaskbase.h"
namespace ZP_Cluster{
//!this class enable server processes can
//! communicate with each other.
class zp_ClusterTerm : public QObject
{
Q_OBJECT
public:
explicit zp_ClusterTerm(const QString & name,int nTransThreads = 4,int nWorkingThreads = 4,QObject *parent = 0);
//cluster status
ZPNetwork::zp_net_ThreadPool * netEng() {return m_pClusterNet;}
ZPTaskEngine::zp_pipeline * taskEng() {return m_pClusterEng;}
bool canExit();
protected:
QString m_strTermName;//the Terminal's name
ZPNetwork::zp_net_ThreadPool * m_pClusterNet;
ZPTaskEngine::zp_pipeline * m_pClusterEng;
signals:
//!this class enable server processes can
//! communicate with each other.
class zp_ClusterTerm : public QObject
{
Q_OBJECT
public:
explicit zp_ClusterTerm(const QString & name,QObject *parent = 0);
//cluster status
ZPNetwork::zp_net_ThreadPool * netEng() {return m_pClusterNet;}
ZPTaskEngine::zp_pipeline * taskEng() {return m_pClusterEng;}
bool canExit();
protected:
QString m_strTermName;//the Terminal's name
ZPNetwork::zp_net_ThreadPool * m_pClusterNet;
ZPTaskEngine::zp_pipeline * m_pClusterEng;
signals:
public slots:
//!Start listen, this term can be connected by newly joined terms in future.
void StartListen(const QHostAddress &addr, int nPort);
//!Join cluster, using existing term (addr:nPort)
//!as soon as connection established, more existing terms will be sent to this term,
//!an p2p connection will start
bool JoinCluster(const QHostAddress &addr, int nPort);
public slots:
//!Start listen, this term can be connected by newly joined terms in future.
void StartListen(const QHostAddress &addr, int nPort);
//!Join cluster, using existing term (addr:nPort)
//!as soon as connection established, more existing terms will be sent to this term,
//!an p2p connection will start
bool JoinCluster(const QHostAddress &addr, int nPort);
};
};
}
#endif // ZP_CLUSTERTERM_H
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册