You're breathtaking!

This commit is contained in:
Wojtek Figat
2020-12-07 23:40:54 +01:00
commit 6fb9eee74c
5143 changed files with 1153594 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
#pragma once
#include "Engine/Platform/Thread.h"
#include "Threading.h"
#include "IRunnable.h"
/// <summary>
/// Helper class to spawn custom thread for performing long-time action. Don't use it for short tasks.
/// </summary>
class FLAXENGINE_API ThreadSpawner
{
public:
/// <summary>
/// Starts a new thread the specified callback.
/// </summary>
/// <param name="callback">The callback function.</param>
/// <param name="threadName">Name of the thread.</param>
/// <param name="priority">The thread priority.</param>
/// <returns>The created thread.</returns>
static Thread* Start(const Function<int32()>& callback, const String& threadName, ThreadPriority priority = ThreadPriority::Normal)
{
auto runnable = New<SimpleRunnable>(true);
runnable->OnWork = callback;
return Thread::Create(runnable, threadName, priority);
}
};