| 125 | ContentService ContentServiceInstance; |
| 126 | |
| 127 | bool ContentService::Init() |
| 128 | { |
| 129 | PROFILE_MEM(Content); |
| 130 | |
| 131 | // Init memory containers |
| 132 | Assets.EnsureCapacity(2048); |
| 133 | LoadedAssetsToInvoke.EnsureCapacity(64); |
| 134 | #if PLATFORM_THREADS_LIMIT > 1 |
| 135 | LoadCallAssets.EnsureCapacity(PLATFORM_THREADS_LIMIT); |
| 136 | #endif |
| 137 | |
| 138 | // Load assets registry |
| 139 | Cache.Init(); |
| 140 | |
| 141 | // Create loading threads |
| 142 | MainLoadThread = New<LoadingThread>(); |
| 143 | ThisLoadThread = MainLoadThread; |
| 144 | #if PLATFORM_THREADS_LIMIT > 1 |
| 145 | const CPUInfo cpuInfo = Platform::GetCPUInfo(); |
| 146 | const int32 count = Math::Clamp(Math::CeilToInt(LOADING_THREAD_PER_LOGICAL_CORE * (float)cpuInfo.LogicalProcessorCount), 1, 12); |
| 147 | LOG(Info, "Creating {0} content loading threads...", count); |
| 148 | LoadThreads.Resize(count); |
| 149 | for (int32 i = 0; i < count; i++) |
| 150 | { |
| 151 | auto thread = New<LoadingThread>(); |
| 152 | LoadThreads[i] = thread; |
| 153 | if (thread->Start(String::Format(TEXT("Load Thread {0}"), i))) |
| 154 | { |
| 155 | LOG(Fatal, "Cannot spawn content thread {0}/{1}", i, count); |
| 156 | Delete(thread); |
| 157 | return true; |
| 158 | } |
| 159 | } |
| 160 | #endif |
| 161 | |
| 162 | return false; |
| 163 | } |
| 164 | |
| 165 | void ContentService::Update() |
| 166 | { |