SHORE API
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
thread_index.hpp
Go to the documentation of this file.
1 
2 /*
3  * Copyright 2008,2009,2010,2011,2012 Stephan Ossowski, Korbinian Schneeberger,
4  * Felix Ott, Joerg Hagmann, Alf Scotland, Sebastian Bender
5  *
6  * This file is part of SHORE.
7  *
8  * SHORE is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * SHORE is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with SHORE. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
25 
26 #ifndef SHORE_PARALLEL_THREAD_INDEX_HPP__
27 #define SHORE_PARALLEL_THREAD_INDEX_HPP__
28 
29 #include <iostream>
30 #include <deque>
31 #include <stdexcept>
32 #include <string>
33 #include <map>
34 #include <vector>
35 
36 #include <boost/thread/thread.hpp>
37 #include <boost/thread/recursive_mutex.hpp>
38 
39 namespace shore {
40 
48 {
49  public:
50 
51  class subscription
52  {
53  private:
54 
55  int m_id;
56  std::string m_info;
57 
58  public:
59 
60  subscription(const std::string &info=std::string());
61  int id() const;
62  const std::string &info() const;
63  std::string label() const;
64  };
65 
66  private:
67 
68  typedef boost::recursive_mutex mutex_type;
69  typedef boost::recursive_mutex::scoped_lock lock_type;
70 
71  static mutex_type m_mutex;
72 
73  static std::map<boost::thread::id,subscription> m_register;
74  static const subscription m_root_subscription;
75 
76  thread_index();
77 
78  public:
79 
80  static int id();
81  static std::string info();
82  static std::string label();
83 };
84 
85 } // namespace
86 
87 #endif // SHORE_PARALLEL_THREAD_INDEX_HPP__
88