2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/internal/event/common/thread-local-storage.h>
22 #include <dali/internal/common/core-impl.h>
23 #include <dali/public-api/common/dali-common.h>
24 #include <dali/internal/event/common/event-thread-services.h>
34 thread_local ThreadLocalStorage* threadLocal = nullptr;
37 ThreadLocalStorage::ThreadLocalStorage(Core* core)
40 DALI_ASSERT_ALWAYS( threadLocal == nullptr && "Cannot create more than one ThreadLocalStorage object" );
45 ThreadLocalStorage::~ThreadLocalStorage()
49 void ThreadLocalStorage::Remove()
51 threadLocal = nullptr;
54 ThreadLocalStorage& ThreadLocalStorage::Get()
56 DALI_ASSERT_ALWAYS(threadLocal);
61 bool ThreadLocalStorage::Created()
63 // see if the TLS has been set yet
64 return (threadLocal != nullptr);
67 ThreadLocalStorage* ThreadLocalStorage::GetInternal()
72 Dali::Integration::PlatformAbstraction& ThreadLocalStorage::GetPlatformAbstraction()
74 return mCore->GetPlatform();
77 SceneGraph::UpdateManager& ThreadLocalStorage::GetUpdateManager()
79 return mCore->GetUpdateManager();
82 NotificationManager& ThreadLocalStorage::GetNotificationManager()
84 return mCore->GetNotificationManager();
87 ShaderFactory& ThreadLocalStorage::GetShaderFactory()
89 return mCore->GetShaderFactory();
92 StagePtr ThreadLocalStorage::GetCurrentStage()
94 return mCore->GetCurrentStage();
97 GestureEventProcessor& ThreadLocalStorage::GetGestureEventProcessor()
99 return mCore->GetGestureEventProcessor();
102 RelayoutController& ThreadLocalStorage::GetRelayoutController()
104 return mCore->GetRelayoutController();
107 ObjectRegistry& ThreadLocalStorage::GetObjectRegistry()
109 return mCore->GetObjectRegistry();
112 EventThreadServices& ThreadLocalStorage::GetEventThreadServices()
114 return mCore->GetEventThreadServices();
117 PropertyNotificationManager& ThreadLocalStorage::GetPropertyNotificationManager()
119 return mCore->GetPropertyNotificationManager();
122 AnimationPlaylist& ThreadLocalStorage::GetAnimationPlaylist()
124 return mCore->GetAnimationPlaylist();
127 void ThreadLocalStorage::AddScene( Scene* scene )
129 mCore->AddScene( scene );
132 void ThreadLocalStorage::RemoveScene( Scene* scene )
134 mCore->RemoveScene( scene );
137 } // namespace Internal