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 <boost/thread/tss.hpp>
26 #include <dali/internal/common/core-impl.h>
27 #include <dali/internal/update/manager/update-manager.h>
28 #include <dali/internal/render/common/render-manager.h>
29 #include <dali/integration-api/platform-abstraction.h>
30 #include <dali/public-api/common/dali-common.h>
31 #include <dali/public-api/math/vector2.h>
42 std::auto_ptr<ThreadLocalStorage> threadLocal;
44 boost::thread_specific_ptr<ThreadLocalStorage> threadLocal;
48 ThreadLocalStorage::ThreadLocalStorage(Core* core)
51 DALI_ASSERT_ALWAYS( threadLocal.get() == NULL && "Cannot create more than one ThreadLocalStorage object" );
53 // reset is used to store a new value associated with this thread
54 threadLocal.reset(this);
58 ThreadLocalStorage::~ThreadLocalStorage()
62 void ThreadLocalStorage::Remove()
67 ThreadLocalStorage& ThreadLocalStorage::Get()
69 ThreadLocalStorage* tls = threadLocal.get();
71 DALI_ASSERT_ALWAYS(tls);
76 bool ThreadLocalStorage::Created()
78 // see if the TLS has been set yet
79 return (threadLocal.get() != NULL);
82 Dali::Integration::PlatformAbstraction& ThreadLocalStorage::GetPlatformAbstraction()
84 return mCore->GetPlatform();
87 SceneGraph::UpdateManager& ThreadLocalStorage::GetUpdateManager()
89 return mCore->GetUpdateManager();
92 NotificationManager& ThreadLocalStorage::GetNotificationManager()
94 return mCore->GetNotificationManager();
97 ResourceManager& ThreadLocalStorage::GetResourceManager()
99 return mCore->GetResourceManager();
102 ResourceClient& ThreadLocalStorage::GetResourceClient()
104 return mCore->GetResourceClient();
107 ImageFactory& ThreadLocalStorage::GetImageFactory()
109 return mCore->GetImageFactory();
112 ModelFactory& ThreadLocalStorage::GetModelFactory()
114 return mCore->GetModelFactory();
117 FontFactory& ThreadLocalStorage::GetFontFactory()
119 return mCore->GetFontFactory();
122 ShaderFactory& ThreadLocalStorage::GetShaderFactory()
124 return mCore->GetShaderFactory();
127 StagePtr ThreadLocalStorage::GetCurrentStage()
129 return mCore->GetCurrentStage();
132 EventToUpdate& ThreadLocalStorage::GetEventToUpdate()
134 return GetUpdateManager().GetEventToUpdate();
137 GestureEventProcessor& ThreadLocalStorage::GetGestureEventProcessor()
139 return mCore->GetGestureEventProcessor();
142 EmojiFactory& ThreadLocalStorage::GetEmojiFactory()
144 return mCore->GetEmojiFactory();
147 } // namespace Internal