1 #ifndef _SOCKET_POOL_H_
2 #define _SOCKET_POOL_H_ 1
7 #include <boost/shared_ptr.hpp>
8 #include <boost/thread.hpp>
13 using namespace boost;
19 SocketPool(int max_streams,
20 asio::io_service &io_svc);
21 void setEndpoint(const tcp::endpoint &endpoint);
22 void cancelAndClear();
23 shared_ptr<tcp::socket> getSocket();
24 void putSocket(shared_ptr<tcp::socket> socket);
29 condition_variable _sockets_non_empty;
30 asio::io_service &_io_service;
31 tcp::endpoint _endpoint;
32 queue<shared_ptr<tcp::socket> > _queue;
33 set<shared_ptr<tcp::socket> > _set;
39 SocketCheckout(SocketPool *pool);
42 tcp::socket& operator*();
43 tcp::socket* operator->();
45 shared_ptr<tcp::socket>& socket();
48 shared_ptr<tcp::socket> _socket;