Remove Emscripten
[platform/core/uifw/dali-core.git] / dali / internal / event / common / thread-local-storage.cpp
1 /*
2  * Copyright (c) 2017 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 // CLASS HEADER
19 #include <dali/internal/event/common/thread-local-storage.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/common/core-impl.h>
23 #include <dali/public-api/common/dali-common.h>
24
25 namespace Dali
26 {
27
28 namespace Internal
29 {
30
31 namespace
32 {
33 __thread ThreadLocalStorage* threadLocal = NULL;
34 }
35
36 ThreadLocalStorage::ThreadLocalStorage(Core* core)
37 : mCore( core )
38 {
39   DALI_ASSERT_ALWAYS( threadLocal == NULL && "Cannot create more than one ThreadLocalStorage object" );
40
41   threadLocal = this;
42 }
43
44 ThreadLocalStorage::~ThreadLocalStorage()
45 {
46 }
47
48 void ThreadLocalStorage::Remove()
49 {
50   threadLocal = NULL;
51 }
52
53 ThreadLocalStorage& ThreadLocalStorage::Get()
54 {
55   DALI_ASSERT_ALWAYS(threadLocal);
56
57   return *threadLocal;
58 }
59
60 bool ThreadLocalStorage::Created()
61 {
62   // see if the TLS has been set yet
63   return (threadLocal != NULL);
64 }
65
66 ThreadLocalStorage* ThreadLocalStorage::GetInternal()
67 {
68   return threadLocal;
69 }
70
71 Dali::Integration::PlatformAbstraction& ThreadLocalStorage::GetPlatformAbstraction()
72 {
73   return mCore->GetPlatform();
74 }
75
76 SceneGraph::UpdateManager& ThreadLocalStorage::GetUpdateManager()
77 {
78   return mCore->GetUpdateManager();
79 }
80
81 NotificationManager& ThreadLocalStorage::GetNotificationManager()
82 {
83   return mCore->GetNotificationManager();
84 }
85
86 ShaderFactory& ThreadLocalStorage::GetShaderFactory()
87 {
88   return mCore->GetShaderFactory();
89 }
90
91 StagePtr ThreadLocalStorage::GetCurrentStage()
92 {
93   return mCore->GetCurrentStage();
94 }
95
96 GestureEventProcessor& ThreadLocalStorage::GetGestureEventProcessor()
97 {
98   return mCore->GetGestureEventProcessor();
99 }
100
101 RelayoutController& ThreadLocalStorage::GetRelayoutController()
102 {
103   return mCore->GetRelayoutController();
104 }
105
106 } // namespace Internal
107
108 } // namespace Dali