This repository was archived by the owner on May 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLThread.h
More file actions
83 lines (58 loc) · 1.37 KB
/
LThread.h
File metadata and controls
83 lines (58 loc) · 1.37 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#pragma once
#include <QThread>
#include <QCoreApplication>
#include <QQueue>
#include <QMutex>
#include <QMap>
#include "Lua/lua.hpp"
#include "ILLibs.h"
class LThread : public QThread
{
Q_OBJECT
public:
LThread(QObject *parent);
~LThread();
bool doFile(QString name);
bool doString(QString str);
bool setId(QString id);
QString getId();
bool destory(QString id);
void beginGlobalTable();
void endGlobalTable(QString name);
void beginTable(QString name);
void endTable();
void addFunction(QString name, lua_CFunction function);
void loadUtils();
static void set_destory(QString destoryId);
bool checkShare(QString key);
void* newShare(QString key, size_t size);
bool removeShare(QString key);
void* getShare(QString key);
size_t sizeShare(QString key);
bool clearShare();
QStringList listShare();
void lockShare();
void unlockShare();
private:
lua_State* lstate = nullptr;
QString lFileName;
QString Id;
QMutex idMutex;
enum class LType {
DoFile,
DoString
};
LType tType = LType::DoFile;
QQueue<QString> strList;
static QString destoryId;
static void hookFunction(lua_State* L, lua_Debug* ar);
QMap<QString, QPair<size_t, void*>> shareData;
QMutex shareMutex;
protected:
void run()override;
signals:
void errorMessage(QString message);
void normalMessage(QString message);
void tStarted(QString id);
void tEnded(QString id);
};