2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
18 #include <dali/internal/event/common/thread-local-storage.h>
21 #include <boost/thread/tss.hpp>
25 #include <dali/internal/common/core-impl.h>
26 #include <dali/internal/update/manager/update-manager.h>
27 #include <dali/internal/render/common/render-manager.h>
28 #include <dali/integration-api/platform-abstraction.h>
29 #include <dali/public-api/common/dali-common.h>
30 #include <dali/public-api/math/vector2.h>
41 std::auto_ptr<ThreadLocalStorage> threadLocal;
43 boost::thread_specific_ptr<ThreadLocalStorage> threadLocal;
47 ThreadLocalStorage::ThreadLocalStorage(Core* core)
50 DALI_ASSERT_ALWAYS( threadLocal.get() == NULL && "Cannot create more than one ThreadLocalStorage object" );
52 // reset is used to store a new value associated with this thread
53 threadLocal.reset(this);
57 ThreadLocalStorage::~ThreadLocalStorage()
61 void ThreadLocalStorage::Remove()
66 ThreadLocalStorage& ThreadLocalStorage::Get()
68 ThreadLocalStorage* tls = threadLocal.get();
70 DALI_ASSERT_ALWAYS(tls);
75 bool ThreadLocalStorage::Created()
77 // see if the TLS has been set yet
78 return (threadLocal.get() != NULL);
81 Dali::Integration::PlatformAbstraction& ThreadLocalStorage::GetPlatformAbstraction()
83 return mCore->GetPlatform();
86 SceneGraph::UpdateManager& ThreadLocalStorage::GetUpdateManager()
88 return mCore->GetUpdateManager();
91 NotificationManager& ThreadLocalStorage::GetNotificationManager()
93 return mCore->GetNotificationManager();
96 ResourceManager& ThreadLocalStorage::GetResourceManager()
98 return mCore->GetResourceManager();
101 ResourceClient& ThreadLocalStorage::GetResourceClient()
103 return mCore->GetResourceClient();
106 ImageFactory& ThreadLocalStorage::GetImageFactory()
108 return mCore->GetImageFactory();
111 ModelFactory& ThreadLocalStorage::GetModelFactory()
113 return mCore->GetModelFactory();
116 FontFactory& ThreadLocalStorage::GetFontFactory()
118 return mCore->GetFontFactory();
121 ShaderFactory& ThreadLocalStorage::GetShaderFactory()
123 return mCore->GetShaderFactory();
126 StagePtr ThreadLocalStorage::GetCurrentStage()
128 return mCore->GetCurrentStage();
131 EventToUpdate& ThreadLocalStorage::GetEventToUpdate()
133 return GetUpdateManager().GetEventToUpdate();
136 GestureEventProcessor& ThreadLocalStorage::GetGestureEventProcessor()
138 return mCore->GetGestureEventProcessor();
141 } // namespace Internal