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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32\sfile\sf_pool.cpp
19 #ifdef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION
20 #include "sf_notifier.h"
21 #endif //SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION
23 //=====CFsPool=============================
26 CFsPool<T>* CFsPool<T>::New(TInt aPoolSize)
28 CFsPool<T>* pool = new CFsPool<T>();
32 TInt r = pool->Construct(aPoolSize);
49 TInt CFsPool<T>::Construct(TInt aPoolSize)
51 TInt r = iPoolLock.CreateLocal(KNotificationPoolSize);
55 r = iFreeList.Reserve(KNotificationPoolSize);
74 //This should only be called by the Manager when it holds
75 //the manager's write lock meaning that all of the
76 //blocks should be unallocated
78 CFsPool<T>::~CFsPool()
80 for(TInt i=0; i < iFreeList.Count(); i++)
89 T* CFsPool<T>::Allocate()
91 Lock(); //Waits when there are no free blocks left
93 TInt lastIndex = iFreeList.Count()-1;
94 T* t = iFreeList[lastIndex];
95 iFreeList.Remove(lastIndex);
101 void CFsPool<T>::Free(T* aBlock)
103 iFreeList.Append(aBlock);
108 void CFsPool<T>::Lock()
114 void CFsPool<T>::Unlock()
119 #ifdef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION
120 //This is needed here because the compiler needs to know which types will be
121 //instantiating the template (because it's in a separate file)
122 template class CFsPool<CFsNotificationBlock>;
123 #endif //SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION