summaryrefslogtreecommitdiff
path: root/platform/qt/src/qmapboxgl_scheduler.hpp
blob: 68636d0d11b46d3a51fe4b03bb0d40886cb8bdec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pragma once

#include <mbgl/actor/mailbox.hpp>
#include <mbgl/actor/scheduler.hpp>
#include <mbgl/util/util.hpp>

#include <QObject>

#include <memory>
#include <mutex>
#include <queue>

class QMapboxGLScheduler : public QObject, public mbgl::Scheduler
{
    Q_OBJECT

public:
    QMapboxGLScheduler();
    virtual ~QMapboxGLScheduler();

    // mbgl::Scheduler implementation.
    void schedule(std::weak_ptr<mbgl::Mailbox> scheduled) final;

    void processEvents();

signals:
    void needsProcessing();

private:
    MBGL_STORE_THREAD(tid);

    std::mutex m_taskQueueMutex;
    std::queue<std::weak_ptr<mbgl::Mailbox>> m_taskQueue;
};