RDK Documentation (Open Sourced RDK Components)
Thread.hpp
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 /*****************************************************************************/
21 /*!
22 \file
23 \brief This file defines interface of Thread class
24 
25 */
26 /*****************************************************************************/
27 
28 
29 /**
30 * @defgroup hdmicec
31 * @{
32 * @defgroup osal
33 * @{
34 **/
35 
36 
37 #include <stdint.h>
38 #include <string>
39 
40 #ifndef HDMI_CCEC_OSAL_THREAD_HPP_
41 #define HDMI_CCEC_OSAL_THREAD_HPP_
42 
43 #include "OSAL.hpp"
44 
45 #include "Runnable.hpp"
46 
47 
48 CCEC_OSAL_BEGIN_NAMESPACE
49 
50 
51 /***************************************************************************/
52 /*!
53 
54 A thread is a thread of execution in a program.
55 An application could have multiple threads of execution running concurrently.
56 
57 A class that needs thread functionality shall implement Runnable interface and
58 object will be passed to Thread on creation of Thread object.
59 On the invocation of start() method of Thread, runnable's run() will be executed
60 in a threaded context.
61 */
62 /**************************************************************************/
63 
64 class Thread : public Runnable {
65 public:
66 /**************************************************************************/
67 /*!
68 \brief Constructor
69 
70  Allocates a new Thread object
71  \param target - Object implements Runnable interface.
72  */
73  /************************************************************************/
74 
75  Thread(Runnable &target);
76 /**************************************************************************/
77 /*!
78 \brief Constructor
79 
80  Allocates a new Thread object
81  \param target - Object implementes Runnable interface.
82  \name - Name of the thread context.
83  */
84  /************************************************************************/
85 
86  Thread(Runnable &target, const int8_t* name);
87 /**************************************************************************/
88 /*!
89 \brief Destructor
90 
91  Destroys the Thread object
92  */
93  /************************************************************************/
94 
95  virtual ~Thread(void);
96 /*!
97 \brief Executes the run() method of runnable object.
98 
99  If this object is created by passing reference to a runnable object, that
100  object's run() will be executed, otherwise this method does nothing and returns.
101  */
102  /************************************************************************/
103 
104  void run(void);
105 
106 /************************************************************************/
107 /*!
108 \brief Starts excecution of the thread.
109 
110  Causes this thread to begin execution;This calls the run method of this thread.
111  The result is that two threads are running concurrently:
112  the current thread (which returns from the call to the start method)
113  and the other thread (which executes its run method).
114  */
115 /***********************************************************************/
116 
117  void start(void);
118 /************************************************************************/
119 /*!
120 \brief Stops execution of thread.
121 
122  Forces the thread to stop executing.
123  */
124 /***********************************************************************/
125 
126  void stop(void);
127 /************************************************************************/
128 /*!
129 \brief Detaches the thread.
130 
131  Detaches the thread.
132  */
133 /***********************************************************************/
134 
135  void detach(void);
136 /************************************************************************/
137 /*!
138 \brief Returns native thread handle.
139 
140  Retrieves native thread handle if thread is started other wise returns null.
141  \return native thread handle.
142  */
143 /***********************************************************************/
144 
145  void *getNativeHandle(void);
146 
147 private:
149  std::string name;
151  static void *CEntry(void * arg);
152 };
153 
154 CCEC_OSAL_END_NAMESPACE
155 
156 #endif
157 
158 
159 /** @} */
160 /** @} */
CCEC_OSAL::Thread
Definition: Thread.hpp:64
CCEC_OSAL::Thread::runnable
Runnable & runnable
Destructor.
Definition: Thread.hpp:148
CCEC_OSAL::Runnable
Definition: Runnable.hpp:37
CCEC_OSAL::Thread::nativeHandle
void * nativeHandle
Destructor.
Definition: Thread.hpp:150
CCEC_OSAL::Thread::name
std::string name
Destructor.
Definition: Thread.hpp:149