From 7a12add219bb486343049bbf7348ab23c8013cc6 Mon Sep 17 00:00:00 2001 From: ponchio Date: Tue, 19 Mar 2013 19:00:14 +0000 Subject: [PATCH] ported to qt5 (but not workinng in qt4.8) --- wrap/gcache/cache.h | 30 +++++++++++++++--------------- wrap/gcache/token.h | 12 ++++++------ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/wrap/gcache/cache.h b/wrap/gcache/cache.h index 62162374..1de6bece 100644 --- a/wrap/gcache/cache.h +++ b/wrap/gcache/cache.h @@ -1,17 +1,17 @@ #ifndef GCACHE_CACHE_H #define GCACHE_CACHE_H -#ifdef _MSC_VER - -typedef __int16 int16_t; -typedef unsigned __int16 uint16_t; -typedef __int32 int32_t; -typedef unsigned __int32 uint32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; - -#else -#include +#ifdef _MSC_VER + +typedef __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; + +#else +#include #endif #include @@ -87,7 +87,7 @@ public: Token *token = &(this->heap[i]); //tokens.push_back(token); s_curr -= drop(token); - assert(!(token->count >= Token::LOCKED)); + assert(!(token->count.load() >= Token::LOCKED)); if(final) token->count.testAndSetOrdered(Token::READY, Token::CACHE); input->heap.push(token); @@ -112,7 +112,7 @@ public: if(functor(token)) { //drop it tokens.push_back(token); s_curr -= drop(token); - assert(token->count < Token::LOCKED); + assert(token->count.load() < Token::LOCKED); if(final) token->count.testAndSetOrdered(Token::READY, Token::CACHE); } else @@ -198,7 +198,7 @@ protected: remove = this->heap.popMin(); } else { last.count.testAndSetOrdered(Token::READY, Token::CACHE); - if(last.count <= Token::CACHE) { //was not locked and now can't be locked, remove it. + if(last.count.load() <= Token::CACHE) { //was not locked and now can't be locked, remove it. remove = this->heap.popMin(); } else { //last item is locked need to reorder stack remove = this->heap.popMin(); @@ -245,7 +245,7 @@ protected: input->rebuild(); //if dirty rebuild if(input->heap.size()) { //we need something in input to tranfer. Token &first = input->heap.max(); - if(first.count > Token::REMOVE && + if(first.count.load() > Token::REMOVE && (!last || first.priority > last->priority)) { //if !last we already decided we want a transfer., otherwise check for a swap insert = input->heap.popMax(); //remove item from heap, while we transfer it. } diff --git a/wrap/gcache/token.h b/wrap/gcache/token.h index dd2a062a..c0a35f9e 100644 --- a/wrap/gcache/token.h +++ b/wrap/gcache/token.h @@ -61,10 +61,10 @@ class Token { bool remove() { count.testAndSetOrdered(READY, REMOVE); count.testAndSetOrdered(CACHE, REMOVE); - return count <= REMOVE; //might have become OUSIDE in the meanwhile + return count.load() <= REMOVE; //might have become OUSIDE in the meanwhile } - bool isLocked() { return count > 0; } + bool isLocked() { return count.load() > 0; } bool isInCache() { return count != OUTSIDE; } //careful, can be used only when provider thread is locked. ///copy priority to swap space [do not use, should be private] @@ -73,14 +73,14 @@ class Token { } bool operator<(const Token &a) const { - if(count == a.count) + if(count.load() == a.count.load()) return priority < a.priority; - return count < a.count; + return count.load() < a.count.load(); } bool operator>(const Token &a) const { - if(count == a.count) + if(count.load() == a.count.load()) return priority > a.priority; - return count > a.count; + return count.load() > a.count.load(); } };