-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

@ -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>

View file

@ -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;

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_

View file

@ -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)