Files
OpenVulkano/openVulkanoCpp/Threading/Task.hpp

31 lines
701 B
C++

/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <functional>
namespace OpenVulkano
{
class Task
{
public:
virtual ~Task() = default;
virtual void Execute() {}
};
class FunctionalTask final : public Task
{
std::function<void()> function;
public:
FunctionalTask(const std::function<void()>& function) : function(function) {}
FunctionalTask(std::function<void()>&& function) : function(std::move(function)) {}
~FunctionalTask() override = default;
void Execute() override { function(); }
};
}