summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-06-06 22:06:58 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-06-06 22:06:58 -0300
commitb524b40fdc5325c840192ce92dbed8108ccef2d9 (patch)
treeec7f74db082b4b91f7614ed4391c53bc73b60bfd /core
parent14c4c1b568ffa40a179332fbc77e9b52c6bdf514 (diff)
-fixed many memory initialization issues
-fixed deadlock on previews thread -fixed compilation errors on unix
Diffstat (limited to 'core')
-rw-r--r--core/command_queue_mt.h4
-rw-r--r--core/io/resource_loader.cpp1
-rw-r--r--core/message_queue.cpp19
-rw-r--r--core/vector.h4
4 files changed, 19 insertions, 9 deletions
diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h
index 0985f3cfe7..113199869b 100644
--- a/core/command_queue_mt.h
+++ b/core/command_queue_mt.h
@@ -34,6 +34,7 @@
#include "os/mutex.h"
#include "os/memory.h"
#include "simple_type.h"
+#include "print_string.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@@ -174,7 +175,7 @@ class CommandQueueMT {
R* ret;
SyncSemaphore *sync;
- virtual void call() { *ret = (instance->*method)(p1); sync->sem->post(); sync->in_use=false; ; }
+ virtual void call() { *ret = (instance->*method)(p1); sync->sem->post(); print_line("post"); sync->in_use=false; ; }
};
template<class T,class M,class P1,class P2,class R>
@@ -675,6 +676,7 @@ public:
if (sync) sync->post();
ss->sem->wait();
+ print_line("wait");
}
template<class T, class M, class P1, class P2,class R>
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 03b6c9759b..22d89840ae 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -214,6 +214,7 @@ RES ResourceLoader::load(const String &p_path,const String& p_type_hint,bool p_n
Ref<ResourceImportMetadata> ResourceLoader::load_import_metadata(const String &p_path) {
+
String local_path;
if (p_path.is_rel_path())
local_path="res://"+p_path;
diff --git a/core/message_queue.cpp b/core/message_queue.cpp
index cfbdb37b88..489939ee65 100644
--- a/core/message_queue.cpp
+++ b/core/message_queue.cpp
@@ -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_
diff --git a/core/vector.h b/core/vector.h
index 04018b9f78..b93d9a0dea 100644
--- a/core/vector.h
+++ b/core/vector.h
@@ -104,7 +104,7 @@ public:
template <class T_val>
- int find(T_val& p_val) const;
+ int find(const T_val& p_val) const;
void set(int p_index,T p_elem);
T get(int p_index) const;
@@ -221,7 +221,7 @@ void Vector<T>::_copy_on_write() {
}
template<class T> template<class T_val>
-int Vector<T>::find(T_val& p_val) const {
+int Vector<T>::find(const T_val &p_val) const {
int ret = -1;
if (size() == 0)