All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IOManager.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef _IOMANAGER_HH_
18 #define _IOMANAGER_HH_
19 
20 #include <boost/thread/thread.hpp>
21 #include <boost/asio.hpp>
22 
23 namespace gazebo
24 {
25  namespace transport
26  {
29 
32  class IOManager
33  {
35  public: IOManager();
37  public: ~IOManager();
38 
41  public: boost::asio::io_service &GetIO();
42 
44  public: void IncCount();
45 
47  public: void DecCount();
48 
51  public: unsigned int GetCount() const;
52 
54  public: void Stop();
55 
56  private: boost::asio::io_service *io_service;
57 
58  // Use io_service::work to keep the io_service running in thread
59  private: boost::asio::io_service::work *work;
60  private: unsigned int count;
61 
62  private: boost::thread *thread;
63  };
65  }
66 }
67 
68 #endif
69 
70