Skip to content

Commit

Permalink
qtcollider: SafePtr, remove locking mechanism
Browse files Browse the repository at this point in the history
It was a bloat, only targeting a potential use case in the future.
If we ever need such locking, we better use/make another shared pointer
class anyway.
  • Loading branch information
jleben committed Oct 1, 2011
1 parent d316dc4 commit 61afba1
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions QtCollider/safeptr.hpp
Expand Up @@ -67,20 +67,13 @@ template<typename T> class SafePtr

void *id() const { return (void*) d; } // useful for checking internal pointer identity

void lock() { if(d) d->mutex.lock(); }

bool tryLock() { return d ? d->mutex.tryLock() : true; }

void unlock() { if(d) d->mutex.unlock(); }

void invalidate() { qcDebugMsg(2,"SafePtr: invalidating"); if(d) d->ptr = 0; }

private:
struct Data {
Data ( T * ptr_ ) : ptr(ptr_), refCount(1) {}
QAtomicPointer<T> ptr;
QAtomicInt refCount;
QMutex mutex;
};

void ref() {
Expand Down

0 comments on commit 61afba1

Please sign in to comment.