2014-11-19 00:25:21 +08:00
|
|
|
|
#pragma once
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../acl_cpp_define.hpp"
|
2014-11-19 00:25:21 +08:00
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
|
|
namespace acl {
|
|
|
|
|
|
|
|
|
|
class beanstalk;
|
|
|
|
|
class locker;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* beanstalk <EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳأ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬʱ<EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD>ͬ<EFBFBD><EFBFBD> beanstalkd <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* ÿ<EFBFBD><EFBFBD> beanstalkd <EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>
|
|
|
|
|
* <EFBFBD>û<EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD>п<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
class ACL_CPP_API beanstalk_pool
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
beanstalk_pool();
|
|
|
|
|
~beanstalk_pool();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD> beanstalkd <EFBFBD>Ŀͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param addr {const char*} beanstalkd <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ(domain:port)
|
|
|
|
|
* @param clean_watch {bool} <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>Զ<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>
|
|
|
|
|
* <EFBFBD>ѹ<EFBFBD>ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param conn_timeout {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> beanstalkd <EFBFBD>ij<EFBFBD>ʱʱ<EFBFBD><EFBFBD>
|
|
|
|
|
* @return {beanstalk*} <EFBFBD><EFBFBD><EFBFBD>طǿձ<EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
beanstalk* peek(const char* addr, bool clean_watch = true,
|
|
|
|
|
int conn_timeout = 60);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD> beanstalkd <EFBFBD><EFBFBD><EFBFBD>ӷŻص<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param client {beanstalk*} beanstalkd <EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param clean_watch {bool} <EFBFBD>Ƿ<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param keep {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ true <EFBFBD><EFBFBD><EFBFBD><EFBFBD> client <EFBFBD>Ż<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳأ<EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷŸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void put(beanstalk* client, bool clean_watch = true,
|
|
|
|
|
bool keep = true);
|
|
|
|
|
private:
|
|
|
|
|
locker* lock_;
|
|
|
|
|
typedef std::multimap<string, beanstalk*> bspool;
|
|
|
|
|
typedef bspool::const_iterator pool_cit;
|
|
|
|
|
typedef bspool::iterator pool_it;
|
|
|
|
|
typedef std::pair<pool_it, pool_it> pool_range;
|
|
|
|
|
|
|
|
|
|
bspool pool_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|