SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Runnable.h
Go to the documentation of this file.
1 #ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
2 /*
3  For more information, please see: http://software.sci.utah.edu
4 
5  The MIT License
6 
7  Copyright (c) 2009 Scientific Computing and Imaging Institute,
8  University of Utah.
9 
10 
11  Permission is hereby granted, free of charge, to any person obtaining a
12  copy of this software and associated documentation files (the "Software"),
13  to deal in the Software without restriction, including without limitation
14  the rights to use, copy, modify, merge, publish, distribute, sublicense,
15  and/or sell copies of the Software, and to permit persons to whom the
16  Software is furnished to do so, subject to the following conditions:
17 
18  The above copyright notice and this permission notice shall be included
19  in all copies or substantial portions of the Software.
20 
21  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  DEALINGS IN THE SOFTWARE.
28 */
29 
30 
31 
32 ///
33 ///@file Runnable
34 ///@brief The base class for all threads
35 ///
36 ///@author Steve Parker
37 /// Department of Computer Science
38 /// University of Utah
39 ///@date June 1997
40 ///
41 
42 #ifndef Core_Thread_Runnable_h
43 #define Core_Thread_Runnable_h
44 
46 
47 namespace SCIRun {
48 
49 /**************************************
50 
51 @class
52  Runnable
53 
54 KEYWORDS
55  Thread
56 
57 @details
58  This class should be a base class for any class which is to be
59  attached to a thread. It provides a <i>run</i> pure virtual method
60  which should be overridden to provide the thread body. When this
61  method returns, or the thread calls <i>Thread::exit</i>, the
62  thread terminates. A <b>Runnable</b> should be attached to
63  only one thread.
64 
65  <p> It is very important that the <b>Runnable</b> object (or any
66  object derived from it) is never explicitly deleted. It will be
67  deleted by the <b>Thread</b> to which it is attached, when the
68  thread terminates. The destructor will be executed in the context
69  of this same thread.
70 
71 ****************************************/
72  class SCISHARE Runnable : boost::noncopyable
73  {
74  protected:
75  //////////
76  /// Create a new runnable, and initialize its state.
77  Runnable(bool delete_on_exit = true);
78 
79  //////////
80  /// The runnable destructor. See the note above about deleting any
81  /// object derived from runnable.
82  virtual ~Runnable();
83 
84  //////////
85  /// This method will be overridden to implement the main body
86  /// of the thread. This method will called when the runnable
87  /// is attached to a <b>Thread</b> object, and will be executed
88  /// in a new context.
89  virtual void run()=0;
90  private:
91  bool delete_on_exit;
92  };
93 } // End namespace SCIRun
94 
95 #endif
96 
97 
98 
99 
100 
101 #endif
#define SCISHARE
Definition: share.h:39