Communication.h
Go to the documentation of this file.
00001 #ifndef CASTOR_NET_COMMUNICATION_H
00002 #define CASTOR_NET_COMMUNICATION_H 1
00003 
00004 #include <boost/thread/mutex.hpp>
00005 #include <boost/bind.hpp>
00006 
00007 #include <asio.hpp>
00008 
00009 #include "CastorChannel.h"
00010 
00011 namespace castor { namespace net {
00012 
00013         class Communication;
00014 
00015         typedef boost::shared_ptr<Communication> CommunicationPtr;
00016 
00017         class Communication {
00018 
00019                 private:
00020 
00021                         static boost::mutex mutex;
00022                         static CommunicationPtr instance;
00023 
00024                         typedef boost::shared_ptr<asio::thread> ThreadPtr;
00025                         typedef std::vector<ThreadPtr> ThreadPool;
00026 
00027                         ThreadPool threadPool;
00028 
00029                 protected:
00030 
00031                         friend class CastorChannel;
00032 
00033                         asio::io_service service;
00034                         bool initialised;
00035 
00036                         Communication();
00037 
00038                 public:
00039 
00040                         virtual ~Communication();
00041 
00042                         static CommunicationPtr getInstance();
00043 
00044                         CastorChannelPtr create(const std::string spec) throw(NetException);
00045                         CastorChannelPtr create(const NetAddress &address) throw(NetException);
00046 
00047                         void run();
00048                         void start(size_t threads = 2);
00049                         void stop();
00050                         void wait();
00051 
00052                         asio::io_service &asioService();
00053         };
00054 
00055 } }
00056 
00057 #endif /* CASTOR_NET_COMMUNICATION_H */
00058 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


Castor
Author(s): Carpe Noctem
autogenerated on Fri Nov 8 2013 11:05:39