summaryrefslogtreecommitdiff
path: root/core/message_queue.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/message_queue.cpp')
-rw-r--r--core/message_queue.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/core/message_queue.cpp b/core/message_queue.cpp
index 2952593798..c57bd4081c 100644
--- a/core/message_queue.cpp
+++ b/core/message_queue.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -271,6 +271,9 @@ void MessageQueue::flush() {
//using reverse locking strategy
_THREAD_SAFE_LOCK_
+ ERR_FAIL_COND(flushing); //already flushing, you did something odd
+ flushing = true;
+
while (read_pos < buffer_end) {
//lock on each iteration, so a call can re-add itself to the message queue
@@ -327,13 +330,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;