Update for thread-safety of EventDrivenThread
[platform/framework/native/appfw.git] / src / base / runtime / FBaseRt_EventDrivenThreadImpl.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_EventDrivenThreadImpl.h
19  * @brief       This is the header file for the _EventDrivenThreadImpl class.
20  *
21  * This file contains the declarations of _EventDrivenThreadImpl.
22  */
23
24 #ifndef _FRT_THREAD_INTERNAL_EVENTDRIVEN_THREAD_IMPL_H_
25 #define _FRT_THREAD_INTERNAL_EVENTDRIVEN_THREAD_IMPL_H_
26
27 #include <glib.h>
28
29 #include <FBaseColLinkedListT.h>
30
31 #include "FBaseRt_EventDispatcher.h"
32 #include "FBaseRt_ThreadImpl.h"
33 #include "FBaseRt_EventDrivenThreadEvent.h"
34 #include "FBaseRt_EventDrivenThreadEventArg.h"
35
36
37 namespace Tizen { namespace Base { namespace Runtime
38 {
39
40 class _EventDrivenThreadImpl
41         : public _ThreadImpl
42         , public _IEventDrivenThreadEventListener
43 {
44 public:
45         _EventDrivenThreadImpl(Thread& thread, const String& name, long stackSize, ThreadPriority priority);
46
47         virtual ~_EventDrivenThreadImpl(void);
48
49         virtual result Stop(void);
50
51         virtual Tizen::Base::Object* Run(void);
52
53         virtual result Initialize(void);
54
55         virtual result SendUserEvent(RequestId requestId, const Tizen::Base::Collection::IList* pArgs);
56
57         virtual void OnUserEventReceivedN(RequestId reqId, Tizen::Base::Collection::IList* pArgs);
58
59         virtual void OnStop(void);
60
61 private:
62         _EventDrivenThreadImpl(const _EventDrivenThreadImpl& value);
63
64         _EventDrivenThreadImpl& operator =(const _EventDrivenThreadImpl& value);
65
66 private:
67         GMainLoop* __pGMainLoop;
68         _EventDispatcher* __pEventDispatcher;
69         _EventManager* __pEventManager;
70         _EventDrivenThreadEvent* __pEvent;
71         GMainContext* __pGmainContext;
72         Tizen::Base::Collection::LinkedListT <_EventDrivenThreadEventArg*> __pendingEvents;
73         Tizen::Base::Runtime::Mutex* __pLock;
74 };
75
76 } } } // Tizen::Base::Runtime
77
78 #endif  // _FRT_THREAD_INTERNAL_EVENTDRIVEN_THREAD_H_