web-utils.cpp
1.41 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
/*
TE4 - T-Engine 4
Copyright (C) 2009, 2010, 2011, 2012, 2013 Nicolas Casalini
No permission to copy or replicate in any ways, awesomium is not gpl so we cant link directly
*/
extern "C" {
#include <stdio.h>
#include "web-external.h"
}
#include "web.h"
#include "web-internal.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;
web_mutex_lock(lock_oqueue);
oqueue->push_back(event);
web_mutex_unlock(lock_oqueue);
}
WebEvent *pop_event()
{
if (!lock_oqueue) return NULL;
WebEvent *event = NULL;
web_mutex_lock(lock_oqueue);
if (!oqueue->empty()) {
event = oqueue->back();
oqueue->pop_back();
}
web_mutex_unlock(lock_oqueue);
return event;
}