userlibandfileserver/fileserver/sfile/sf_pool.h
changeset 300 1d28c8722707
parent 0 a41df078684a
equal deleted inserted replaced
293:0659d0e1a03c 300:1d28c8722707
    25  */
    25  */
    26 template <class T>
    26 template <class T>
    27 class CFsPool
    27 class CFsPool
    28 	{
    28 	{
    29 public:
    29 public:
    30 	static CFsPool<T>* New(TInt aPoolSize);
    30    
       
    31 	static CFsPool<T>* New(TInt aPoolSize,T*(*aNewFunction)());
    31 	~CFsPool();
    32 	~CFsPool();
    32 	
    33 	
    33 	/*
    34 	/*
    34 	 * Allocate returns a pointer of class T.
    35 	 * Allocate returns a pointer of class T.
    35 	 * The pointer returned is removed from the pool.
    36 	 * The pointer returned is removed from the pool.
    36 	 * When the pool is empty this function will wait.
    37 	 * WAITs when the pool is empty.
    37 	 */
    38 	 */
    38 	T* Allocate();
    39 	T* Allocate();
    39 	
    40 	
    40 	/*
    41 	/*
    41 	 * Following a call to Allocate,
    42 	 * Following a call to Allocate,
    42 	 * Free teturns an object-pointer of type T to the pool.
    43 	 * Free teturns an object-pointer of type T to the pool.
    43 	 */
    44 	 */
    44 	void Free(T* aBlock);
    45 	void Free(T* aBlock);
    45 private:
    46 private:
    46 	CFsPool();
    47 	CFsPool();
    47 	TInt Construct(TInt aPoolSize);
    48 	TInt Construct(TInt aPoolSize,T*(*aNewFunction)());
    48 	
    49 	
    49 	void Lock();
    50 	void Lock();
    50 	void Unlock();
    51 	void Unlock();
    51 	RSemaphore iPoolLock;
    52 	RSemaphore iPoolLock;
    52 		
    53