Fix the boiler plate codes
[platform/framework/native/appfw.git] / src / base / runtime / FBaseRt_ThreadImpl.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file        FBaseRt_ThreadImpl.h
19  * @brief       This is the header file for the %_ThreadImpl class.
20  *
21  * This file contains the declarations of the %_ThreadImpl class.
22  */
23
24 #ifndef _FBASE_RT_INTERNAL_THREAD_IMPL_H_
25 #define _FBASE_RT_INTERNAL_THREAD_IMPL_H_
26
27 #include <pthread.h>
28
29 #include <FBaseRtThread.h>
30 #include "FBaseRt_EventManager.h"
31
32 namespace Tizen { namespace Base { namespace Runtime
33 {
34
35 class _OSP_EXPORT_ _ThreadImpl
36         : public Tizen::Base::Object
37         , public Tizen::Base::Runtime::IRunnable
38 {
39 public:
40         _ThreadImpl(Thread& thread, const Tizen::Base::String& name, long stackSize
41                                 , ThreadPriority priority, ThreadType threadType);
42
43         virtual ~_ThreadImpl(void);
44
45         virtual result Start(void);
46
47         virtual result Stop(void);
48
49         virtual result SendUserEvent(RequestId requestId, const Tizen::Base::Collection::IList* pArgs);
50
51         result Join(void);
52
53         result GetExitCode(int& exitCode) const;
54
55         const Tizen::Base::String& GetName(void) const;
56
57         ThreadType GetThreadType(void) const;
58
59         void SetEventManager(_EventManager* pEventManager);
60
61         _EventManager* GetEventManager(void);
62
63         virtual Tizen::Base::Object* Run(void);
64
65         static void Exit(int exitCode);
66
67         static result Sleep(long milliSeconds);
68
69         static result Yield(void);
70
71         static Thread* GetCurrentThread(void);
72
73         static _ThreadImpl* GetCurrentThreadImpl(void);
74
75 protected:
76         virtual result Initialize(void);
77
78         virtual result Finalize(void);
79
80         const Thread* GetThread(void) const;
81
82         const ThreadPriority GetPriority(void) const;
83
84         void SetThread(Thread* pThread);
85
86         void SetNativeThread(pthread_t nativeThread);
87
88 private:
89         static void* ThreadProc(void* pParam);
90
91 protected:
92         Thread* _pThread;
93
94 private:
95         String __name;
96         long __stackSize;
97         ThreadPriority __priority;
98         ThreadType __threadType;
99         pthread_t __nativeThread;
100         int __exitCode;
101         _EventManager* __pEventManager;
102 }; // _ThreadImpl
103
104 } } } // Tizen::Base::Runtime
105
106 #endif  // _FBASE_RT_INTERNAL_THREAD_IMPL_H_