#include "async_task_impl.hpp" #include #include #include namespace mbgl { namespace util { AsyncTask::Impl::Impl(std::function&& fn) : runLoop(RunLoop::Get()), task(std::move(fn)) { connect(this, SIGNAL(send(void)), this, SLOT(runTask(void)), Qt::QueuedConnection); } void AsyncTask::Impl::maySend() { if (!queued.test_and_set()) { emit send(); } } void AsyncTask::Impl::runTask() { assert(runLoop == RunLoop::Get()); queued.clear(); task(); } AsyncTask::AsyncTask(std::function&& fn) : impl(std::make_unique(std::move(fn))) { } AsyncTask::~AsyncTask() { } void AsyncTask::send() { impl->maySend(); } } }