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 2011 Nate Koenig
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 
31  class IOManager
32  {
33  public: IOManager();
34  public: ~IOManager();
35 
36  public: boost::asio::io_service &GetIO();
37 
38  public: void IncCount();
39  public: void DecCount();
40  public: unsigned int GetCount() const;
41 
42  public: void Stop();
43 
44  private: boost::asio::io_service *io_service;
45 
46  // Use io_service::work to keep the io_service running in thread
47  private: boost::asio::io_service::work *work;
48  private: unsigned int count;
49 
50  private: boost::thread *thread;
51  };
53  }
54 }
55 
56 #endif
57 
58