aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/source/flcontainers.h
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2005-03-08 04:57:17 +0000
committerThomas Grill <xovo@users.sourceforge.net>2005-03-08 04:57:17 +0000
commitdfcbb9904402efc8f0deec2a16bd905b911da0aa (patch)
tree70e23992a3ad440ccab7c54946e3b00de3b82433 /externals/grill/flext/source/flcontainers.h
parent8a3c1f78e0b705aa3fa02ff4b842cbc53906824c (diff)
updated flext lock-free containers
install flcontainers.h Lifos and Fifos with reservoir forgot about void... svn path=/trunk/; revision=2601
Diffstat (limited to 'externals/grill/flext/source/flcontainers.h')
-rw-r--r--externals/grill/flext/source/flcontainers.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/externals/grill/flext/source/flcontainers.h b/externals/grill/flext/source/flcontainers.h
index ad32055a..a97df172 100644
--- a/externals/grill/flext/source/flcontainers.h
+++ b/externals/grill/flext/source/flcontainers.h
@@ -270,13 +270,14 @@ public:
inline T *Pop() { return static_cast<T *>(Lifo::Pop()); }
};
-template <typename T>
+template <typename T,int M = 2,int O = 1>
class PooledLifo
: public TypedLifo<T>
{
public:
inline T *New() { T *n = reuse.Pop(); return n?n:new T; }
- inline Free(T *p) { if(reuse.Size() < Size()) reuse.Push(p); else delete p; }
+ inline size_t Size() const { return TypedLifo<T>::Size(); }
+ inline void Free(T *p) { if(reuse.Size() < Size()*M+O) reuse.Push(p); else delete p; }
private:
TypedLifo<T> reuse;
};
@@ -347,13 +348,14 @@ public:
inline T *Clear() { return static_cast<T *>(Fifo::Clear()); }
};
-template <typename T>
+template <typename T,int M = 2,int O = 1>
class PooledFifo
: public TypedFifo<T>
{
public:
inline T *New() { T *n = reuse.Pop(); return n?n:new T; }
- inline Free(T *p) { if(reuse.Size() < Size()) reuse.Push(p); else delete p; }
+ inline size_t Size() const { return TypedFifo<T>::Size(); }
+ inline void Free(T *p) { if(reuse.Size() < Size()*M+O) reuse.Push(p); else delete p; }
private:
TypedLifo<T> reuse;
};