2019-07-28 10:31:56 +08:00
|
|
|
class redis_thread : public acl::thread
|
2018-11-30 14:38:22 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
redis_thread(const char* addr, const char* passwd, int conn_timeout,
|
2021-01-03 18:03:58 +08:00
|
|
|
int rw_timeout, int fibers_max, int stack_size,
|
|
|
|
int oper_count, const char* cmd);
|
|
|
|
redis_thread(acl::redis_client_cluster& cluster, int fibers_max,
|
|
|
|
int stack_size, int oper_count, const char* cmd);
|
2018-11-30 14:38:22 +08:00
|
|
|
|
2018-12-16 16:47:51 +08:00
|
|
|
~redis_thread(void);
|
2018-11-30 14:38:22 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
acl::redis_client_cluster& get_cluster(void)
|
|
|
|
{
|
2018-12-16 16:47:51 +08:00
|
|
|
return *cluster_;
|
2018-11-30 14:38:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int get_fibers_max(void) const
|
|
|
|
{
|
|
|
|
return fibers_max_;
|
|
|
|
}
|
|
|
|
|
|
|
|
int get_oper_count(void) const
|
|
|
|
{
|
|
|
|
return oper_count_;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct timeval& get_begin(void)
|
|
|
|
{
|
|
|
|
return begin_;
|
|
|
|
}
|
|
|
|
|
2021-01-03 18:03:58 +08:00
|
|
|
const acl::string& get_cmd(void) const {
|
|
|
|
return cmd_;
|
|
|
|
}
|
|
|
|
|
2018-11-30 14:38:22 +08:00
|
|
|
void fiber_dec(int cnt);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void *run(void);
|
|
|
|
|
|
|
|
private:
|
|
|
|
acl::string addr_;
|
|
|
|
acl::string passwd_;
|
|
|
|
int conn_timeout_;
|
|
|
|
int rw_timeout_;
|
|
|
|
int fibers_max_;
|
|
|
|
int fibers_cnt_;
|
|
|
|
int stack_size_;
|
|
|
|
int oper_count_;
|
2021-01-03 18:03:58 +08:00
|
|
|
acl::string cmd_;
|
|
|
|
|
2018-11-30 14:38:22 +08:00
|
|
|
struct timeval begin_;
|
2018-12-16 16:47:51 +08:00
|
|
|
acl::redis_client_cluster* cluster_;
|
|
|
|
acl::redis_client_cluster* cluster_internal_;
|
2018-11-30 14:38:22 +08:00
|
|
|
|
|
|
|
static void fiber_redis(ACL_FIBER *fiber, void *ctx);
|
|
|
|
};
|