ThreadedComponent.h
Go to the documentation of this file.
1 /*
2  * This file is protected by Copyright. Please refer to the COPYRIGHT file
3  * distributed with this source distribution.
4  *
5  * This file is part of REDHAWK core.
6  *
7  * REDHAWK core is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * REDHAWK core is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this program. If not, see http://www.gnu.org/licenses/.
19  */
20 
21 #ifndef OSSIE_THREADEDCOMPONENT_H
22 #define OSSIE_THREADEDCOMPONENT_H
23 #include "ossie/ProcessThread.h"
24 #include "ossie/Autocomplete.h"
25 
26 enum {
27  NOOP = 0,
28  FINISH = -1,
29  NORMAL = 1
30 };
31 
32 //
33 // Mix-in class for threaded components and devices
34 //
36 public:
37  virtual ~ThreadedComponent ();
38 
39  // Main work function (to be implemented by subclass)
40  virtual int serviceFunction () = 0;
41 
42 protected:
44 
45  // Starts the processing thread, if necessary
46  void startThread ();
47 
48  // Stops the processing thread, if necessary
49  bool stopThread ();
50 
51  // Returns the current delay between calls to service function after a NOOP
52  float getThreadDelay ();
53 
54  // Changes the delay between calls to service function after a NOOP
55  void setThreadDelay (float delay);
56 
57  ossie::ProcessThread* serviceThread;
58  boost::mutex serviceThreadLock;
59 
60 private:
61  float _defaultDelay;
62 };
63 
64 #endif // OSSIE_THREADEDCOMPONENT_H
virtual ~ThreadedComponent()
void setThreadDelay(float delay)
boost::mutex serviceThreadLock
Definition: ThreadedComponent.h:58
Definition: ThreadedComponent.h:28
ossie::ProcessThread * serviceThread
Definition: ThreadedComponent.h:57
float getThreadDelay()
Definition: ThreadedComponent.h:27
virtual int serviceFunction()=0
Definition: ThreadedComponent.h:35
Definition: ThreadedComponent.h:29