我做了一个dbpool类,创建了一个线程池,每个线程开了一个mysql的链接,dbpool里面有请求队列,包括低级优先级查询队列,高级优先级查询队列。
那么问题来了,客户端登陆,然后服务器的业务线程提交了一个查询的sql到了dbpool的查询队列,业务层怎么等待数据库的返回?
那么问题来了,客户端登陆,然后服务器的业务线程提交了一个查询的sql到了dbpool的查询队列,业务层怎么等待数据库的返回?
调试欢乐多
将查询的sql封装成结构
Item{
int weight
string sql
boost::function<....> callback
}把
Item push到dbpool里面的请求队列
then how could get the result back? asynchronously? dbpool maintains a result message queue?business thread may have to be hung up in order to wait for the completion of the query. condition wait here?