web-utils.cpp
2.43 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
TE4 - T-Engine 4
Copyright (C) 2009 - 2018 Nicolas Casalini
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Nicolas Casalini "DarkGod"
darkgod@te4.org
*/
extern "C" {
#include "tSDL.h"
#include "tgl.h"
#include "web-external.h"
#include <stdio.h>
}
#include "web.h"
#include "web-internal.h"
#include <cef_app.h>
#include <cef_app.h>
#include <cef_client.h>
#include <cef_display_handler.h>
#include <cef_render_handler.h>
#include <cef_request_handler.h>
#include <cef_render_process_handler.h>
#include <vector>
static std::vector<WebEvent*> *iqueue = new std::vector<WebEvent*>;
static std::vector<WebEvent*> *oqueue = new std::vector<WebEvent*>;
static void *lock_iqueue = NULL;
static void *lock_oqueue = NULL;
void te4_web_init_utils() {
if (!lock_iqueue) lock_iqueue = web_mutex_create();
if (!lock_oqueue) lock_oqueue = web_mutex_create();
}
void push_order(WebEvent *event)
{
if (!lock_iqueue) return;
web_mutex_lock(lock_iqueue);
iqueue->push_back(event);
web_mutex_unlock(lock_iqueue);
}
WebEvent *pop_order()
{
if (!lock_iqueue) return NULL;
WebEvent *event = NULL;
web_mutex_lock(lock_iqueue);
if (!iqueue->empty()) {
event = iqueue->back();
iqueue->pop_back();
}
web_mutex_unlock(lock_iqueue);
return event;
}
void push_event(WebEvent *event)
{
if (!lock_oqueue) return;
// fprintf(logfile, "[WEBCORE] <Event push %d\n", event->kind);
web_mutex_lock(lock_oqueue);
oqueue->push_back(event);
web_mutex_unlock(lock_oqueue);
// fprintf(logfile, "[WEBCORE] >Event push %d\n", event->kind);
}
WebEvent *pop_event()
{
if (!lock_oqueue) return NULL;
WebEvent *event = NULL;
// fprintf(logfile, "[WEBCORE] <Event pop\n");
web_mutex_lock(lock_oqueue);
if (!oqueue->empty()) {
event = oqueue->back();
oqueue->pop_back();
}
web_mutex_unlock(lock_oqueue);
// fprintf(logfile, "[WEBCORE] >Event pop\n");
return event;
}