2
0
Fork 0
OB-Xd/Modules/gin/utilities/asyncutilities.h
2020-05-21 09:14:57 +02:00

40 lines
883 B
C++
Executable file

/*==============================================================================
Copyright 2018 by Roland Rabien
For more information visit www.rabiensoftware.com
==============================================================================*/
#pragma once
class LambdaTimer : public Timer
{
public:
LambdaTimer (std::function<void()> func = nullptr) : onTimer (func) {}
std::function<void()> onTimer;
private:
void timerCallback() override
{
if (onTimer)
onTimer();
}
};
class LambdaAsyncUpdater : public AsyncUpdater
{
public:
LambdaAsyncUpdater (std::function<void()> func) : onAsyncUpdate (func) {}
std::function<void()> onAsyncUpdate;
private:
void handleAsyncUpdate () override
{
if (onAsyncUpdate)
onAsyncUpdate();
}
};
void callOnMainThreadBlocking ( std::function<void ()> func );