2 * Copyright (c) 2014 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>
33 __thread ThreadLocalStorage* threadLocal = NULL;
36 ThreadLocalStorage::ThreadLocalStorage(Core* core)
38 #ifdef DALI_DYNAMICS_SUPPORT
39 , mDynamicsWorldInstance( NULL )
42 DALI_ASSERT_ALWAYS( threadLocal == NULL && "Cannot create more than one ThreadLocalStorage object" );
44 // reset is used to store a new value associated with this thread
48 ThreadLocalStorage::~ThreadLocalStorage()
52 void ThreadLocalStorage::Remove()
54 #ifdef DALI_DYNAMICS_SUPPORT
55 if( mDynamicsWorldInstance )
57 mDynamicsWorldInstance.Reset();
63 ThreadLocalStorage& ThreadLocalStorage::Get()
65 DALI_ASSERT_ALWAYS(threadLocal);
70 bool ThreadLocalStorage::Created()
72 // see if the TLS has been set yet
73 return (threadLocal != NULL);
76 ThreadLocalStorage* ThreadLocalStorage::GetInternal()
81 #ifdef DALI_DYNAMICS_SUPPORT
82 Dali::Internal::DynamicsWorldPtr ThreadLocalStorage::GetDynamicsWorldInstance()
84 if( !mDynamicsWorldInstance )
86 // Create the instance if it doesn't exist.
87 mDynamicsWorldInstance = DynamicsWorld::New();
89 return mDynamicsWorldInstance;
93 Dali::Integration::PlatformAbstraction& ThreadLocalStorage::GetPlatformAbstraction()
95 return mCore->GetPlatform();
98 SceneGraph::UpdateManager& ThreadLocalStorage::GetUpdateManager()
100 return mCore->GetUpdateManager();
103 NotificationManager& ThreadLocalStorage::GetNotificationManager()
105 return mCore->GetNotificationManager();
108 ResourceManager& ThreadLocalStorage::GetResourceManager()
110 return mCore->GetResourceManager();
113 ResourceClient& ThreadLocalStorage::GetResourceClient()
115 return mCore->GetResourceClient();
118 ImageFactory& ThreadLocalStorage::GetImageFactory()
120 return mCore->GetImageFactory();
123 ShaderFactory& ThreadLocalStorage::GetShaderFactory()
125 return mCore->GetShaderFactory();
128 StagePtr ThreadLocalStorage::GetCurrentStage()
130 return mCore->GetCurrentStage();
133 GestureEventProcessor& ThreadLocalStorage::GetGestureEventProcessor()
135 return mCore->GetGestureEventProcessor();
138 RelayoutController& ThreadLocalStorage::GetRelayoutController()
140 return mCore->GetRelayoutController();
143 } // namespace Internal