summaryrefslogtreecommitdiffstats
path: root/core/message_queue.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2019-01-14 10:59:28 -0300
committerJuan Linietsky <reduzio@gmail.com>2019-01-14 11:00:05 -0300
commit4bb0080b3df28a3003bfffd6285602664a4279c9 (patch)
tree5d73152adb5a1cae699fcbbceb2d79355378ac75 /core/message_queue.cpp
parentc6b587636b1e3cf27e566e6e5b10859316cbefb6 (diff)
downloadredot-engine-4bb0080b3df28a3003bfffd6285602664a4279c9.tar.gz
Do not allow adding tasks while in the middle of flushing a message queue
Diffstat (limited to 'core/message_queue.cpp')
-rw-r--r--core/message_queue.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/message_queue.cpp b/core/message_queue.cpp
index 7c3bdfec53..27da2c099a 100644
--- a/core/message_queue.cpp
+++ b/core/message_queue.cpp
@@ -271,6 +271,8 @@ void MessageQueue::flush() {
//using reverse locking strategy
_THREAD_SAFE_LOCK_
+ flushing = true;
+
while (read_pos < buffer_end) {
//lock on each iteration, so a call can re-add itself to the message queue
@@ -327,13 +329,20 @@ void MessageQueue::flush() {
}
buffer_end = 0; // reset buffer
+ flushing = false;
_THREAD_SAFE_UNLOCK_
}
+bool MessageQueue::is_flushing() const {
+
+ return flushing;
+}
+
MessageQueue::MessageQueue() {
ERR_FAIL_COND(singleton != NULL);
singleton = this;
+ flushing = false;
buffer_end = 0;
buffer_max_used = 0;