1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QQMLDELAYEDCALLQUEUE_P_H |
5 | #define QQMLDELAYEDCALLQUEUE_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtCore/qglobal.h> |
19 | #include <QtCore/qobject.h> |
20 | #include <QtCore/qmetaobject.h> |
21 | #include <QtCore/qmetatype.h> |
22 | #include <private/qqmlguard_p.h> |
23 | #include <private/qv4context_p.h> |
24 | |
25 | QT_BEGIN_NAMESPACE |
26 | |
27 | class QQmlV4Function; |
28 | |
29 | class QQmlDelayedCallQueue : public QObject |
30 | { |
31 | Q_OBJECT |
32 | public: |
33 | QQmlDelayedCallQueue(); |
34 | ~QQmlDelayedCallQueue() override; |
35 | |
36 | void init(QV4::ExecutionEngine *); |
37 | |
38 | static QV4::ReturnedValue addUniquelyAndExecuteLater(QV4::ExecutionEngine *engine, |
39 | QQmlV4Function *args); |
40 | |
41 | public Q_SLOTS: |
42 | void ticked(); |
43 | |
44 | private: |
45 | struct DelayedFunctionCall |
46 | { |
47 | DelayedFunctionCall() {} |
48 | DelayedFunctionCall(QV4::PersistentValue function) |
49 | : m_function(function), m_guarded(false) { } |
50 | |
51 | void execute(QV4::ExecutionEngine *engine) const; |
52 | |
53 | QV4::PersistentValue m_function; |
54 | QV4::PersistentValue m_args; |
55 | QQmlGuard<QObject> m_objectGuard; |
56 | bool m_guarded; |
57 | }; |
58 | |
59 | void storeAnyArguments(DelayedFunctionCall& dfc, QQmlV4Function *args, int offset, QV4::ExecutionEngine *engine); |
60 | void executeAllExpired_Later(); |
61 | |
62 | QV4::ExecutionEngine *m_engine; |
63 | QVector<DelayedFunctionCall> m_delayedFunctionCalls; |
64 | QMetaMethod m_tickedMethod; |
65 | bool m_callbackOutstanding; |
66 | }; |
67 | |
68 | QT_END_NAMESPACE |
69 | |
70 | #endif // QQMLDELAYEDCALLQUEUE_P_H |
71 | |