Skip to content

Instantly share code, notes, and snippets.

@Appendme

Appendme/task.cpp Secret

Created Nov 7, 2019
Embed
What would you like to do?
#include "pch.h"
#include "task.h"
namespace AIMP
{
Task::Task(TaskFunc calledFunc)
: _func(calledFunc)
{
}
Task::~Task()
{
_func = nullptr;
}
void WINAPI Task::Execute(IAIMPTaskOwner* owner)
{
if (owner->IsCanceled()) return;
if (_func)
_func(owner);
}
}
#pragma once
#include "unknown.h"
#include <functional>
namespace AIMP
{
#include "sdk/apiThreading.h"
using TaskFunc = void(__stdcall*)(IAIMPTaskOwner*);
//using TaskFunc = std::function<void(IAIMPTaskOwner*)>;
class Task
: public UnknownII<IAIMPTask>
{
public:
Task(TaskFunc calledFunc);
~Task();
void WINAPI Execute(IAIMPTaskOwner* owner) override;
private:
TaskFunc _func;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.