os/kernelhwsrv/userlibandfileserver/fileserver/sfile/sf_pool.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // f32\sfile\sf_pool.h
    15 // 
    16 //
    17 
    18 #include "sf_std.h"
    19 
    20 #ifndef SF_POOL_H_
    21 #define SF_POOL_H_
    22 
    23 /**
    24  * @internalTechnology
    25  */
    26 template <class T>
    27 class CFsPool
    28 	{
    29 public:
    30 	static CFsPool<T>* New(TInt aPoolSize);
    31 	~CFsPool();
    32 	
    33 	/*
    34 	 * Allocate returns a pointer of class T.
    35 	 * The pointer returned is removed from the pool.
    36 	 * When the pool is empty this function will wait.
    37 	 */
    38 	T* Allocate();
    39 	
    40 	/*
    41 	 * Following a call to Allocate,
    42 	 * Free teturns an object-pointer of type T to the pool.
    43 	 */
    44 	void Free(T* aBlock);
    45 private:
    46 	CFsPool();
    47 	TInt Construct(TInt aPoolSize);
    48 	
    49 	void Lock();
    50 	void Unlock();
    51 	RSemaphore iPoolLock;
    52 		
    53 	RPointerArray<T> iFreeList;
    54 	};
    55 
    56 #endif /* SF_POOL_H_ */