199dd5949SShuo Chen// excerpts from http://code.google.com/p/muduo/
299dd5949SShuo Chen//
399dd5949SShuo Chen// Use of this source code is governed by a BSD-style license
499dd5949SShuo Chen// that can be found in the License file.
599dd5949SShuo Chen//
699dd5949SShuo Chen// Author: Shuo Chen (chenshuo at chenshuo dot com)
799dd5949SShuo Chen
899dd5949SShuo Chen#ifndef MUDUO_NET_EVENTLOOPTHREADPOOL_H
999dd5949SShuo Chen#define MUDUO_NET_EVENTLOOPTHREADPOOL_H
1099dd5949SShuo Chen
1199dd5949SShuo Chen#include "thread/Condition.h"
1299dd5949SShuo Chen#include "thread/Mutex.h"
1399dd5949SShuo Chen#include "thread/Thread.h"
1499dd5949SShuo Chen
1599dd5949SShuo Chen
1699dd5949SShuo Chen#include <vector>
1799dd5949SShuo Chen#include <boost/function.hpp>
1899dd5949SShuo Chen#include <boost/noncopyable.hpp>
1999dd5949SShuo Chen#include <boost/ptr_container/ptr_vector.hpp>
2099dd5949SShuo Chen
2199dd5949SShuo Chennamespace muduo
2299dd5949SShuo Chen{
2399dd5949SShuo Chen
2499dd5949SShuo Chenclass EventLoop;
2599dd5949SShuo Chenclass EventLoopThread;
2699dd5949SShuo Chen
2799dd5949SShuo Chenclass EventLoopThreadPool : boost::noncopyable
2899dd5949SShuo Chen{
2999dd5949SShuo Chen public:
3099dd5949SShuo Chen  EventLoopThreadPool(EventLoop* baseLoop);
3199dd5949SShuo Chen  ~EventLoopThreadPool();
3299dd5949SShuo Chen  void setThreadNum(int numThreads) { numThreads_ = numThreads; }
3399dd5949SShuo Chen  void start();
3499dd5949SShuo Chen  EventLoop* getNextLoop();
3599dd5949SShuo Chen
3699dd5949SShuo Chen private:
3799dd5949SShuo Chen  EventLoop* baseLoop_;
3899dd5949SShuo Chen  bool started_;
3999dd5949SShuo Chen  int numThreads_;
4099dd5949SShuo Chen  int next_;  // always in loop thread
4199dd5949SShuo Chen  boost::ptr_vector<EventLoopThread> threads_;
4299dd5949SShuo Chen  std::vector<EventLoop*> loops_;
4399dd5949SShuo Chen};
4499dd5949SShuo Chen
4599dd5949SShuo Chen}
4699dd5949SShuo Chen
4799dd5949SShuo Chen#endif  // MUDUO_NET_EVENTLOOPTHREADPOOL_H
48