sl@0: // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // f32\sfile\sf_pool.h sl@0: // sl@0: // sl@0: sl@0: #include "sf_std.h" sl@0: sl@0: #ifndef SF_POOL_H_ sl@0: #define SF_POOL_H_ sl@0: sl@0: /** sl@0: * @internalTechnology sl@0: */ sl@0: template sl@0: class CFsPool sl@0: { sl@0: public: sl@0: static CFsPool* New(TInt aPoolSize); sl@0: ~CFsPool(); sl@0: sl@0: /* sl@0: * Allocate returns a pointer of class T. sl@0: * The pointer returned is removed from the pool. sl@0: * When the pool is empty this function will wait. sl@0: */ sl@0: T* Allocate(); sl@0: sl@0: /* sl@0: * Following a call to Allocate, sl@0: * Free teturns an object-pointer of type T to the pool. sl@0: */ sl@0: void Free(T* aBlock); sl@0: private: sl@0: CFsPool(); sl@0: TInt Construct(TInt aPoolSize); sl@0: sl@0: void Lock(); sl@0: void Unlock(); sl@0: RSemaphore iPoolLock; sl@0: sl@0: RPointerArray iFreeList; sl@0: }; sl@0: sl@0: #endif /* SF_POOL_H_ */