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>
24 #include <dali/internal/common/core-impl.h>
25 #include <dali/internal/update/manager/update-manager.h>
26 #include <dali/internal/render/common/render-manager.h>
27 #include <dali/integration-api/platform-abstraction.h>
28 #include <dali/public-api/common/dali-common.h>
29 #include <dali/public-api/math/vector2.h>
39 boost::thread_specific_ptr<ThreadLocalStorage> threadLocal;
42 ThreadLocalStorage::ThreadLocalStorage(Core* core)
45 DALI_ASSERT_ALWAYS( threadLocal.get() == NULL && "Cannot create more than one ThreadLocalStorage object" );
47 // reset is used to store a new value associated with this thread
48 threadLocal.reset(this);
52 ThreadLocalStorage::~ThreadLocalStorage()
56 void ThreadLocalStorage::Remove()
61 ThreadLocalStorage& ThreadLocalStorage::Get()
63 ThreadLocalStorage* tls = threadLocal.get();
65 DALI_ASSERT_ALWAYS(tls);
70 bool ThreadLocalStorage::Created()
72 // see if the TLS has been set yet
73 return (threadLocal.get() != NULL);
76 Dali::Integration::PlatformAbstraction& ThreadLocalStorage::GetPlatformAbstraction()
78 return mCore->GetPlatform();
81 SceneGraph::UpdateManager& ThreadLocalStorage::GetUpdateManager()
83 return mCore->GetUpdateManager();
86 NotificationManager& ThreadLocalStorage::GetNotificationManager()
88 return mCore->GetNotificationManager();
91 ResourceManager& ThreadLocalStorage::GetResourceManager()
93 return mCore->GetResourceManager();
96 ResourceClient& ThreadLocalStorage::GetResourceClient()
98 return mCore->GetResourceClient();
101 ImageFactory& ThreadLocalStorage::GetImageFactory()
103 return mCore->GetImageFactory();
106 ModelFactory& ThreadLocalStorage::GetModelFactory()
108 return mCore->GetModelFactory();
111 FontFactory& ThreadLocalStorage::GetFontFactory()
113 return mCore->GetFontFactory();
116 ShaderFactory& ThreadLocalStorage::GetShaderFactory()
118 return mCore->GetShaderFactory();
121 StagePtr ThreadLocalStorage::GetCurrentStage()
123 return mCore->GetCurrentStage();
126 EventToUpdate& ThreadLocalStorage::GetEventToUpdate()
128 return GetUpdateManager().GetEventToUpdate();
131 GestureEventProcessor& ThreadLocalStorage::GetGestureEventProcessor()
133 return mCore->GetGestureEventProcessor();
136 } // namespace Internal