1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-08 12:40:44 +00:00

-fixed many memory initialization issues

-fixed deadlock on previews thread
-fixed compilation errors on unix
This commit is contained in:
Juan Linietsky
2015-06-06 22:06:58 -03:00
parent 14c4c1b568
commit b524b40fdc
23 changed files with 80 additions and 41 deletions

View File

@@ -324,6 +324,7 @@ int MessageQueue::get_max_buffer_usage() const {
void MessageQueue::flush() {
if (buffer_max_used<buffer_end); {
buffer_max_used=buffer_end;
//statistics();
@@ -331,9 +332,14 @@ void MessageQueue::flush() {
uint32_t read_pos=0;
while (read_pos < buffer_end ) {
//using reverse locking strategy
_THREAD_SAFE_LOCK_
while (read_pos<buffer_end) {
_THREAD_SAFE_UNLOCK_
//lock on each interation, so a call can re-add itself to the message queue
_THREAD_SAFE_LOCK_
Message *message = (Message*)&buffer[ read_pos ];
@@ -379,16 +385,17 @@ void MessageQueue::flush() {
}
read_pos+=sizeof(Message);
uint32_t advance = sizeof(Message);
if (message->type!=TYPE_NOTIFICATION)
read_pos+=sizeof(Variant)*message->args;
advance+=sizeof(Variant)*message->args;
message->~Message();
_THREAD_SAFE_UNLOCK_
_THREAD_SAFE_LOCK_
read_pos+=advance;
}
_THREAD_SAFE_LOCK_
buffer_end=0; // reset buffer
_THREAD_SAFE_UNLOCK_