SHORE API
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
thread.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_HPP__
27 #define SHORE_PARALLEL_THREAD_HPP__
28 
29 #include <sstream>
30 #include <stdexcept>
31 
32 #include <boost/thread/recursive_mutex.hpp>
33 
35 
36 namespace shore {
37 
39 class thread
40 {
41  private:
42 
43  friend class shore::uncaught_handler;
44 
45  typedef boost::recursive_mutex mutex_type;
46  typedef boost::recursive_mutex::scoped_lock lock_type;
47  typedef shore::uncaught_handler::Status status_type;
48 
49  mutex_type m_mutex;
50 
51  std::string m_name;
52 
53  status_type m_status;
54  std::string m_threaderrors;
55 
56 
57  void call_run();
58 
59 
60  protected:
61 
62  virtual void run() {}
63  virtual void onjoin() {}
64 
65  mutex_type &mutex();
66 
67  public:
68 
69  thread(const std::string &name);
70  virtual ~thread() {}
71 
72  shore::uncaught_handler::Status status();
73 
74  std::string errors();
75 
76  virtual void operator()();
77 };
78 
79 } // namespace
80 
81 #endif // SHORE_PARALLEL_THREAD_HPP__
82