summaryrefslogtreecommitdiff
path: root/Widgets/EventLoop.h
blob: ca8b912bc0225482a1244176337adad7190c46e5 (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
#pragma once

#include <AK/OwnPtr.h>
#include <AK/Vector.h>

class Event;
class Object;

class EventLoop {
public:
    virtual ~EventLoop();

    int exec();

    virtual void waitForEvent() = 0;

    void postEvent(Object* receiver, OwnPtr<Event>&&);

    static EventLoop& main();

protected:
    EventLoop();

private:
    struct QueuedEvent {
        Object* receiver { nullptr };
        OwnPtr<Event> event;
    };
    Vector<QueuedEvent> m_queuedEvents;
};