Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/WolfireGames/overgrowth.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Asset/assetmanagerthreadhandler.h')
-rw-r--r--Source/Asset/assetmanagerthreadhandler.h84
1 files changed, 84 insertions, 0 deletions
diff --git a/Source/Asset/assetmanagerthreadhandler.h b/Source/Asset/assetmanagerthreadhandler.h
new file mode 100644
index 00000000..0a9cf66e
--- /dev/null
+++ b/Source/Asset/assetmanagerthreadhandler.h
@@ -0,0 +1,84 @@
+//-----------------------------------------------------------------------------
+// Name: assetmanagerthreadhandler.h
+// Developer: Wolfire Games LLC
+// Description:
+// License: Read below
+//-----------------------------------------------------------------------------
+//
+//
+// Copyright 2022 Wolfire Games LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-----------------------------------------------------------------------------
+#pragma once
+
+#include <Internal/integer.h>
+#include <Asset/assetloaderbase.h>
+
+#include <thread>
+#include <mutex>
+#include <chrono>
+
+struct AssetLoaderThreadedInstance {
+ AssetLoaderThreadedInstance();
+ AssetLoaderThreadedInstance( AssetLoaderBase* loader, uint32_t load_id, int step );
+
+ AssetLoaderBase* loader;
+ uint32_t load_id;
+ int step;
+ int return_state;
+};
+
+class AssetManagerThreadedInstanceQueue {
+public:
+ AssetManagerThreadedInstanceQueue();
+ ~AssetManagerThreadedInstanceQueue();
+
+ AssetLoaderThreadedInstance Pop();
+ void Push(const AssetLoaderThreadedInstance& input);
+ size_t Count();
+
+private:
+ std::mutex* accessmutex;
+
+ AssetLoaderThreadedInstance *queue;
+ size_t queue_count;
+ size_t queue_size;
+};
+
+
+class AssetManagerThreadInstance {
+public:
+ bool* stop;
+ AssetManagerThreadedInstanceQueue* queue_in;
+ AssetManagerThreadedInstanceQueue* queue_out;
+
+ AssetManagerThreadInstance(AssetManagerThreadedInstanceQueue* queue_in, AssetManagerThreadedInstanceQueue* queue_out, bool* stop);
+};
+
+class AssetManagerThreadHandler {
+public:
+ AssetManagerThreadedInstanceQueue queue_in;
+ AssetManagerThreadedInstanceQueue queue_out;
+
+ AssetManagerThreadHandler(int thread_count);
+ ~AssetManagerThreadHandler();
+private:
+
+ std::vector<std::thread*> threads;
+
+ bool stop;
+};
+
+void AssetManagerThreadHandler_Operate(void* data);