aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSipaha2017-08-21 01:10:44 +0700
committerRémi Verschelde2017-08-27 12:49:09 +0200
commita6b160660cdd932a1437ad0b04087e6c63c2e2c8 (patch)
treeb05f8693ec6e1b54242b0e5488873b199983898a
parent802fab11e4d63851ed36fc4e2a54a000c3c4ee18 (diff)
downloadgodot-a6b160660cdd932a1437ad0b04087e6c63c2e2c8.tar.gz
godot-a6b160660cdd932a1437ad0b04087e6c63c2e2c8.tar.zst
godot-a6b160660cdd932a1437ad0b04087e6c63c2e2c8.zip
Move wait_for_flush out of queue lock
(cherry picked from commit f6ee4cac39fa83a1691f102760b7f008403acdc2)
-rw-r--r--core/command_queue_mt.cpp2
-rw-r--r--core/command_queue_mt.h63
2 files changed, 47 insertions, 18 deletions
diff --git a/core/command_queue_mt.cpp b/core/command_queue_mt.cpp
index 0ab031558..f84be46da 100644
--- a/core/command_queue_mt.cpp
+++ b/core/command_queue_mt.cpp
@@ -54,6 +54,7 @@ CommandQueueMT::SyncSemaphore *CommandQueueMT::_alloc_sync_sem() {
while (true) {
+ lock();
for (int i = 0; i < SYNC_SEMAPHORES; i++) {
if (!sync_sems[i].in_use) {
@@ -62,6 +63,7 @@ CommandQueueMT::SyncSemaphore *CommandQueueMT::_alloc_sync_sem() {
break;
}
}
+ unlock();
if (idx == -1) {
wait_for_flush();
diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h
index 92e255d9b..2722051c6 100644
--- a/core/command_queue_mt.h
+++ b/core/command_queue_mt.h
@@ -801,12 +801,14 @@ public:
template <class T, class M, class R>
void push_and_ret(T *p_instance, M p_method, R *r_ret) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandRet0<T, M, R> *cmd = allocate_and_lock<CommandRet0<T, M, R> >();
cmd->instance = p_instance;
cmd->method = p_method;
cmd->ret = r_ret;
- SyncSemaphore *ss = _alloc_sync_sem();
+
cmd->sync = ss;
unlock();
@@ -818,13 +820,15 @@ public:
template <class T, class M, class P1, class R>
void push_and_ret(T *p_instance, M p_method, P1 p1, R *r_ret) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandRet1<T, M, P1, R> *cmd = allocate_and_lock<CommandRet1<T, M, P1, R> >();
cmd->instance = p_instance;
cmd->method = p_method;
cmd->p1 = p1;
cmd->ret = r_ret;
- SyncSemaphore *ss = _alloc_sync_sem();
+
cmd->sync = ss;
unlock();
@@ -836,6 +840,8 @@ public:
template <class T, class M, class P1, class P2, class R>
void push_and_ret(T *p_instance, M p_method, P1 p1, P2 p2, R *r_ret) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandRet2<T, M, P1, P2, R> *cmd = allocate_and_lock<CommandRet2<T, M, P1, P2, R> >();
cmd->instance = p_instance;
@@ -843,7 +849,7 @@ public:
cmd->p1 = p1;
cmd->p2 = p2;
cmd->ret = r_ret;
- SyncSemaphore *ss = _alloc_sync_sem();
+
cmd->sync = ss;
unlock();
@@ -855,6 +861,8 @@ public:
template <class T, class M, class P1, class P2, class P3, class R>
void push_and_ret(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, R *r_ret) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandRet3<T, M, P1, P2, P3, R> *cmd = allocate_and_lock<CommandRet3<T, M, P1, P2, P3, R> >();
cmd->instance = p_instance;
@@ -863,7 +871,7 @@ public:
cmd->p2 = p2;
cmd->p3 = p3;
cmd->ret = r_ret;
- SyncSemaphore *ss = _alloc_sync_sem();
+
cmd->sync = ss;
unlock();
@@ -875,6 +883,8 @@ public:
template <class T, class M, class P1, class P2, class P3, class P4, class R>
void push_and_ret(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, R *r_ret) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandRet4<T, M, P1, P2, P3, P4, R> *cmd = allocate_and_lock<CommandRet4<T, M, P1, P2, P3, P4, R> >();
cmd->instance = p_instance;
@@ -884,7 +894,7 @@ public:
cmd->p3 = p3;
cmd->p4 = p4;
cmd->ret = r_ret;
- SyncSemaphore *ss = _alloc_sync_sem();
+
cmd->sync = ss;
unlock();
@@ -896,6 +906,8 @@ public:
template <class T, class M, class P1, class P2, class P3, class P4, class P5, class R>
void push_and_ret(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, R *r_ret) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandRet5<T, M, P1, P2, P3, P4, P5, R> *cmd = allocate_and_lock<CommandRet5<T, M, P1, P2, P3, P4, P5, R> >();
cmd->instance = p_instance;
@@ -906,7 +918,7 @@ public:
cmd->p4 = p4;
cmd->p5 = p5;
cmd->ret = r_ret;
- SyncSemaphore *ss = _alloc_sync_sem();
+
cmd->sync = ss;
unlock();
@@ -918,6 +930,8 @@ public:
template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class R>
void push_and_ret(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, R *r_ret) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandRet6<T, M, P1, P2, P3, P4, P5, P6, R> *cmd = allocate_and_lock<CommandRet6<T, M, P1, P2, P3, P4, P5, P6, R> >();
cmd->instance = p_instance;
@@ -929,7 +943,7 @@ public:
cmd->p5 = p5;
cmd->p6 = p6;
cmd->ret = r_ret;
- SyncSemaphore *ss = _alloc_sync_sem();
+
cmd->sync = ss;
unlock();
@@ -941,6 +955,8 @@ public:
template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class R>
void push_and_ret(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, R *r_ret) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandRet7<T, M, P1, P2, P3, P4, P5, P6, P7, R> *cmd = allocate_and_lock<CommandRet7<T, M, P1, P2, P3, P4, P5, P6, P7, R> >();
cmd->instance = p_instance;
@@ -953,7 +969,7 @@ public:
cmd->p6 = p6;
cmd->p7 = p7;
cmd->ret = r_ret;
- SyncSemaphore *ss = _alloc_sync_sem();
+
cmd->sync = ss;
unlock();
@@ -965,6 +981,8 @@ public:
template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class R>
void push_and_ret(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, R *r_ret) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandRet8<T, M, P1, P2, P3, P4, P5, P6, P7, P8, R> *cmd = allocate_and_lock<CommandRet8<T, M, P1, P2, P3, P4, P5, P6, P7, P8, R> >();
cmd->instance = p_instance;
@@ -978,7 +996,7 @@ public:
cmd->p7 = p7;
cmd->p8 = p8;
cmd->ret = r_ret;
- SyncSemaphore *ss = _alloc_sync_sem();
+
cmd->sync = ss;
unlock();
@@ -990,12 +1008,13 @@ public:
template <class T, class M>
void push_and_sync(T *p_instance, M p_method) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandSync0<T, M> *cmd = allocate_and_lock<CommandSync0<T, M> >();
cmd->instance = p_instance;
cmd->method = p_method;
- SyncSemaphore *ss = _alloc_sync_sem();
cmd->sync = ss;
unlock();
@@ -1007,13 +1026,14 @@ public:
template <class T, class M, class P1>
void push_and_sync(T *p_instance, M p_method, P1 p1) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandSync1<T, M, P1> *cmd = allocate_and_lock<CommandSync1<T, M, P1> >();
cmd->instance = p_instance;
cmd->method = p_method;
cmd->p1 = p1;
- SyncSemaphore *ss = _alloc_sync_sem();
cmd->sync = ss;
unlock();
@@ -1025,6 +1045,8 @@ public:
template <class T, class M, class P1, class P2>
void push_and_sync(T *p_instance, M p_method, P1 p1, P2 p2) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandSync2<T, M, P1, P2> *cmd = allocate_and_lock<CommandSync2<T, M, P1, P2> >();
cmd->instance = p_instance;
@@ -1032,7 +1054,6 @@ public:
cmd->p1 = p1;
cmd->p2 = p2;
- SyncSemaphore *ss = _alloc_sync_sem();
cmd->sync = ss;
unlock();
@@ -1044,6 +1065,8 @@ public:
template <class T, class M, class P1, class P2, class P3>
void push_and_sync(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandSync3<T, M, P1, P2, P3> *cmd = allocate_and_lock<CommandSync3<T, M, P1, P2, P3> >();
cmd->instance = p_instance;
@@ -1052,7 +1075,6 @@ public:
cmd->p2 = p2;
cmd->p3 = p3;
- SyncSemaphore *ss = _alloc_sync_sem();
cmd->sync = ss;
unlock();
@@ -1064,6 +1086,8 @@ public:
template <class T, class M, class P1, class P2, class P3, class P4>
void push_and_sync(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandSync4<T, M, P1, P2, P3, P4> *cmd = allocate_and_lock<CommandSync4<T, M, P1, P2, P3, P4> >();
cmd->instance = p_instance;
@@ -1073,7 +1097,6 @@ public:
cmd->p3 = p3;
cmd->p4 = p4;
- SyncSemaphore *ss = _alloc_sync_sem();
cmd->sync = ss;
unlock();
@@ -1085,6 +1108,8 @@ public:
template <class T, class M, class P1, class P2, class P3, class P4, class P5>
void push_and_sync(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandSync5<T, M, P1, P2, P3, P4, P5> *cmd = allocate_and_lock<CommandSync5<T, M, P1, P2, P3, P4, P5> >();
cmd->instance = p_instance;
@@ -1095,7 +1120,6 @@ public:
cmd->p4 = p4;
cmd->p5 = p5;
- SyncSemaphore *ss = _alloc_sync_sem();
cmd->sync = ss;
unlock();
@@ -1107,6 +1131,8 @@ public:
template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6>
void push_and_sync(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandSync6<T, M, P1, P2, P3, P4, P5, P6> *cmd = allocate_and_lock<CommandSync6<T, M, P1, P2, P3, P4, P5, P6> >();
cmd->instance = p_instance;
@@ -1118,7 +1144,6 @@ public:
cmd->p5 = p5;
cmd->p6 = p6;
- SyncSemaphore *ss = _alloc_sync_sem();
cmd->sync = ss;
unlock();
@@ -1130,6 +1155,8 @@ public:
template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7>
void push_and_sync(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandSync7<T, M, P1, P2, P3, P4, P5, P6, P7> *cmd = allocate_and_lock<CommandSync7<T, M, P1, P2, P3, P4, P5, P6, P7> >();
cmd->instance = p_instance;
@@ -1142,7 +1169,6 @@ public:
cmd->p6 = p6;
cmd->p7 = p7;
- SyncSemaphore *ss = _alloc_sync_sem();
cmd->sync = ss;
unlock();
@@ -1154,6 +1180,8 @@ public:
template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
void push_and_sync(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandSync8<T, M, P1, P2, P3, P4, P5, P6, P7, P8> *cmd = allocate_and_lock<CommandSync8<T, M, P1, P2, P3, P4, P5, P6, P7, P8> >();
cmd->instance = p_instance;
@@ -1167,7 +1195,6 @@ public:
cmd->p7 = p7;
cmd->p8 = p8;
- SyncSemaphore *ss = _alloc_sync_sem();
cmd->sync = ss;
unlock();